How to plot a "global" legend when using subplots?

Take this example:

using Plots
pla = plot(x->x^2, title="Plot A", legend=nothing);plot!(x->x^3)
plb = plot(x->x^(1/2), title="Plot B", legend=nothing);plot!(x->x^(1/3))
plot(pla,plb,plb,pla,layout=(2,2),plot_title="Two plots", labels=["Serie1" "Serie2"],legend = :outerbottom)

Producing:

Is there a way to provide a single global legend, a bit like plot_title ?

Probably not. But could you clarify what you want it to look like?

If you’re willing to use Makie then this can be done with GridLayout() and a Legend() function call (though you could just use regular Axes()).

Apologies if you know this and are intentionally Plots.jl for some other reason

In Plots.jl there are two ways to do this: (i) using insets, (ii) using layouts.

1 Like