Makie: Labels aren't added automatically by mutating methods
MWE with WGLMakie 0.13.6 and DD 0.29.24:
g = Figure()
ax = Axis(g[1, 1])
lines!(ax, rand(X(50)); label="Foo")
g
I'd expect mutating methods to behave like their non-mutating counterparts and add a label.
It is added - just not shown. Try calling axislegend
g = Figure()
ax = Axis(g[1, 1])
lines!(ax, rand(X(50)); label="Foo")
axislegend(ax)
g
If you want to add an axis label, it has to be an argument to Axis. Plot labels are only shown in legends
Then why does lines() show it automatically?
lines(rand(X(50)); label="Foo")
Using axislegend() looks a bit funky if both lines() and lines!() is used:
g = Figure()
lines(g[1, 1], rand(X(50)); label="Foo")
lines!(g[1, 1], rand(X(50)); label="Bar")
axislegend()
g
Yeah this is why we shouldn't do it by default 🤷
Also Makie is just kinda cumbersome in some ways.
axislegend should update itself and it's weird that it doesn't. Its probably even an observable already.
(The plots here are meant to instantly show you what you have using all available labelling)
So the real issue is that lines(rand(X(50)); label="Foo") already shows the legend.
Compare to lines(rand(50); label = "Foo"):
That's because we hack it in DD. That has already caused problems in PyramidScheme but I think PS also shows a way forward here with the makie recipe changes I made.
Yeah. But again, I have to say the real problem is that Makie does not update the legend with new data, even though it could.
Automatically adding a legend is an obvious thing to do for a package that facilitates naming everything.
The relevant Makie issue to push for is https://github.com/MakieOrg/Makie.jl/issues/3207
Haha I even forgot I made that issue.