Adjusting padding between axis and axisticklabel in gridded layout

This question is about being able to adjust the space between ticklabels and their corresponding axis lines in the default GR backed for Plots.jl.

Consider:

using Plots, Plots.Measures
minx, miny, N = 300, 300, 16

Plots.plot([Plots.plot(margin=0) for i in range(1,N*N)]..., layout=(N,N), 
           size=N.*(minx,miny), margin=0mm, ytickfonthalign=:left, dpi=200)

This generates a gridded layout as expected, except there is a humungous amount of space between the yticklabels and the y-axis. Funnily enough ytickfonthalign=:left actually reduces the space and ytickfonthalign=:left increases it. But more importantly, as you increase N the said spacing between the ticklabels and their axis actually keeps increasing.

Does anyone know how to reduce it? Setting negative margins didn’t help.

For such a large number of subplots, while that gr() backend bug is not fixed, it is best to use the plotly() backend.

Example:

using Measures, Plots; plotly()
N = 16
l = @layout grid(N, N)
plot(rand(10,N*N), layout=l, tickfontsize=5, margin=1mm, size=(200,200).*N)

Thanks for this.

How do I save to PDF with the plotly backend?

It seems I can only save to HTML file format? Everything else keeps giving me this unhelpful error message:

julia> t=LinRange(0, 4π, 200);
julia> pp = plot(t, sin.(t))
julia> savefig(pp, "testfile.pdf")
ERROR: MethodError: no method matching _show(::IOStream, ::MIME{Symbol("application/pdf")}, ::Plots.Plot{Plots.PlotlyBackend})
Closest candidates are:
  _show(::IO, ::MIME{Symbol("application/pdf")}, ::Plots.Plot{Plots.GRBackend}) at ~/.julia/packages/Plots/9Q9pN/src/backends/gr.jl:2028
  _show(::IO, ::MIME{Symbol("application/vnd.plotly.v1+json")}, ::Plots.Plot{Plots.PlotlyBackend}) at ~/.julia/packages/Plots/9Q9pN/src/backends/plotly.jl:1102
  _show(::IO, ::MIME{Symbol("text/html")}, ::Plots.Plot{Plots.PlotlyBackend}) at ~/.julia/packages/Plots/9Q9pN/src/backends/plotly.jl:1105
  ...

I have fiddled around with the plotlyjs backend and it only got more complicated.

If you will, open a new thread for a new topic.