Makie read legend color

Is it possible to read back the colors from an existing Legend, or axis?

I don’t quite understand, you want to know what colors the legend elements have?

For instance, if I called two lines!:

fig = ...
ax = ...
lines!(ax, xs, label="A")
lines!(ax, ys, label="B")
legend = Legend(fig[1, 2], ax)

Now I would like to know what color is assigned to A and B

1 Like

Is this what you need? lines! returns a line object that you can get the colour of by accessing line.color. The lines are contained in ax.scene.plots

fig = Figure()
ax = Axis(fig[1, 1])
l1=lines!(ax, rand(10), label="A")
l2=lines!(ax, rand(10), label="B")
legend = Legend(fig[1, 2], ax)

#from the lines:
l1.color[]
l2.color[]

#from the axis if you did not assign l1 and l2:
ax.scene.plots[1].color[]
ax.scene.plots[2].color[]