JuliaPlots / Plots.jl

Powerful convenience for Julia visualizations and data analysis
https://docs.juliaplots.org
Other
1.84k stars 355 forks source link

Better default padding around plot in GR with personalize limits [FR] #3223

Open Ezequiel92 opened 3 years ago

Ezequiel92 commented 3 years ago

When using personalized limits with big fonts in GR the tick labels can get cut-off.

For example, consider this MWE

using Plots

plot(data_linear, xlim=(0, 10), ylim=(0, 1), xtickfontsize=30, ytickfontsize=30)
savefig("gr_limits_collition.png")

you get

gr_limits_collition

With a bigger plot, there is still clipping, for example with

using Plots

plot(data_linear, xlim=(0, 10), ylim=(0, 1), xtickfontsize=30, ytickfontsize=30, size=(1000,1000))
savefig("gr_limits_collition.png")

you get

gr_limits_collition

In contrast PGFPlotsX works just fine with its defaults

using Plots
pgfplotsx()

plot(rand(10), xlim=(0, 10), ylim=(0, 1), xtickfontsize=30, ytickfontsize=30)
savefig("pgfplotsx_limits_collition.png")

gives

pgfplotsx_limits_collition

(even without the legend there is no clipping).

I know that the trivial fix is to use left and top margins. That is way I put this as an enhancement and not a bug, as it would be nice if the defaults worked just fine across backends.

Versions

From julia> versioninfo()

Julia Version 1.5.3
Commit 788b2c77c1 (2020-11-09 13:37 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)

From (@v1.5) pkg> status

[91a5bcdd] Plots v1.10.1

From (@v1.5) pkg> st -m

[28b8d3ca] GR v0.53.0
[d2c73de3] GR_jll v0.53.0+0
FelixBenning commented 3 years ago

when using marker those get also sliced up. So if you have dynamic sizes where you use the maximum and minimum of your data you will end up with those being sliced up

BeastyBlacksmith commented 3 years ago

well that is really a feature of latex (and hence pgfplots) that it will append as much space as needed to show any content. The outcome is that the figure of the pgfplotsx-backend will have a different size than what is specified in the defaults, while GR will always have exactly the size you tell it. Note, that you can increase the margin via margins = 2Plots.cm or similar.