I am working with Plots.jl
and I’d like to have more flexibility to adjust the spacings in the plots. I provide below a short piece of code that requires Plots.jl
as an example that serves to drive the point home.
For this case, the spacing issues I’m dealing with are directly linked to the style of the plots. The frame style for the plots has to be :box
and the legend has to be in the :outterbottom
. If we run the piece of code provided, we’ll get the plot below. And as we see in the plot, I’d like to tackle the spacing between the title (rectangle in red) and the empty space in the bottom of the plot (rectangle in blue).
Plots.jl
, as far as I know, doesn’t provide the option of a “subtitle”. For the plots I need, I’m using a two-line tile. As you can, the second line of the title sits too close to the upper part of the :box
. Ideally, the spacing would adjust automatically, especially because there is space in the plot to move things around. Having a legend and a xlab
leaves too much empty space.
I have tried using Plots.PlotMeasures
so I could play with the margin
. I’m not sure if I missed something, but changing margins didn’t do much. Do you know how I can adjust these spacings?
# Generate data
x = collect(1:100)
y = (2 .* x) .+ x .* randn(100)
# Plot data
plot(x,
y,
xlab = "Time steps",
label = "My data",
title = "This is a title \nAnd this is kind of a subtitle",
titlelocation=:left,
framestyle=:box,
dpi=600,
legend=:outerbottom,
legend_columns=-1,
fg_legend=:transparent)