How to move the legend to outside the plotting area in Plots.jl (GR)?

This is now easily enabled with Plots.jl:

Example:

plot(rand(10), legend = :outertopleft)

enter image description here


Using layouts I can create a workaround making a fake plot with legend only.

using Plots
gr()
l = @layout [a{0.001h}; b c{0.13w}]

values = rand(1:100,(10,10))

p1 = groupedbar(values,bar_position=:stack, legend=:none)
p2 = groupedbar(values,bar_position=:stack, label="item".*map(string,collect(1:10)), grid=false, xlims=(20,3), showaxis=false)


p0=plot(title="Title",grid=false, showaxis=false)

plot(p0,p1,p2,layout=l)

enter image description here

Tags:

Julia

Plots.Jl