Wrapping label text in Plots.jl

Try this:

using Plots; pgfplotsx()
default(legend_font_halign=:left)

x = 1:10; y1, y2 = sin.(x)./x, cos.(x)./x
label1a = "this is a very long pgfplotsx() label, "^2
label1b = "split into a new line"
label2a = "here is another quite long label, "^2
label2b = "split into a new line"
plot(x, y1, label=label1a, legend=:topright, fg_legend=nothing);
plot!([x[1]], [y1[1]], lc=:white, label=label1b);
plot!(x, y2, label=label2a);
plot!([x[1]], [y1[1]], lc=:white, label=label2b)

4 Likes