Yes, it is possible. We need to apply appropriate logic to the left_margin and right_margin keyword arguments to get:
Plots.jl code updated
using Plots, DataFrames, Dates, Measures
dfd = DataFrame(
:Date => [sum([Date(Dates.now()), Dates.Day(i)]) for i in 1:60],
:Return => randn(60) ./100,
:A => repeat(collect(1:5), inner = 12),
:B => repeat(collect(1:12), inner = 5)
)
gdf = groupby(dfd, [:B])
n_rows = 3
n_cols = div(length(gdf), 3)
p = [ Plots.plot(gdf[i].Date, gdf[i].Return, legend_position = false,
rotation = 45, title = "B = $i", titlefontsize = 8, xtickfontsize = 6,
ygrid = true, yticks = true, ytickfontsize = (i%n_cols==1) ? 6 : 1,
y_foreground_color_text = (i%n_cols==1) ? :black : :transparent,
left_margin = (i%n_cols==1) ? 5mm : -2mm,
right_margin = (i%n_cols==0) ? 2mm : -2mm) for i in 1:12
]
yl = extrema(dfd.Return)
plt_panel = Plots.plot(p..., ylims = yl,
size = (4000 / 4, 700), layout = (n_rows, n_cols),
legend = false, plot_title = "Hello", bottom_margin = 5mm
)
