Plots - how to add padding between subplots

plotting
#1

The obvious choice is to specify margin attribute but it actually controls the margin space around the subplots but not including the labels. That means a wider margin would make the labels farther apart from the graph. Is there any way to keep the labels close to the subplots but instead control the margin between the subplots? (My definition of subplot includes the labels, too.)

MWE:

histogram(randn(1000,4), layout = 4,xlims=(-4,4),leg=false,
        xaxis = "Values",yaxis = "Density", margin = 20px)
0 Likes

#2

I am having the same problem. The work around I am using is to add “\n” to the labels (e.g. xlab=“Label\n”) and then setting the margins to accommodate for that (e.g. bottom_margin=20px).
Eg.

p1 = plot(x,y1, xlab="Some label\n");
p2 = plot(x,y2 xlab="Some label\n");
plot(p1, p2, bottom_margin=20px)

Not the best solution (and it does not work with LaTeXStrings), but I could not find anything else in the docs.

0 Likes