Two lines one label - Makie

Hi,

From the basic tutorials we have the code

fig = Figure()
ax1, l1 = lines(fig[1, 1], 0..10, sin, color = :red)
ax2, l2 = lines(fig[2, 1], 0..10, cos, color = :blue)
Legend(fig[1:2, 2], [l1, l2], ["sin", "cos"])
fig

Which produces

I am wondering if there would be a way such that in the legend the red and blue line could be attributed to the label “sin”?

I have tried various things to no success.

Cheers,
harry

You mean like two parallel lines, one red, one blue, next to the sin entry?

Yes that is what I mean :slight_smile:

Not using the label shortcut currently, I think. Or at least not directly. But you can build the LineElements yourself, specifying the points so they don’t overlap:

 f = Figure()
 Legend(f[1, 1], [[LineElement(color = :red, points = Point2f[(0, 0.75), (1, 0.75)]), LineElement(color = :blue, points = Point2f[(0, 0.25), (1, 0.25)])]], ["sin"])
 f