julia> using Plots; funcs=[sin,cos,sinh,cosh];
julia> p = plot(funcs,-6,6,link=:both,layout=4,title=reshape(map(string,funcs),1,4),leg=false)
julia> for i=1:2; plot!(p[i],xformatter=_->""); plot!(p[2i],yformatter=_->""); end; p
I set the formatter to always return an empty string, so that the ticks will still be there (so the grid lines will be drawn). If you don’t care about the grid, you can also set xticks=nothing.
That’s perfect - I was using dev at the time, which had an issue that I see you have already fixed. Didn’t know about xformatter and yformatter but they will be very useful. Amazing work as usual. Thanks!
The reason for this is subtle, and hard to fix generically. When you build a plot from existing subplots, there is an extra layer of layout. Specifically, there’s a 2x2 grid layout where each cell contains a 1x1 grid layout. I guess the alignment logic isn’t passing through multiple recursive layers in the way you would hope.
Ideally the fix would come from within Plots, but since my time is limited, you’ll have to fix it yourself. There’s another way to do this if you want to define each plot individually:
p = plot(layout=4, link=:both, leg=false)
for (i,f) in enumerate(funcs)
plot!(p[i], f, -6, 6, title=string(f))
end
p
This builds the layout but doesn’t add any series initially. Then you can add to a specific subplot by indexing into the Plot object. Note: you could also do p[row,column] in this case to get a specific subplot.