DimensionalData.jl icon indicating copy to clipboard operation
DimensionalData.jl copied to clipboard

Makie: Labels aren't added automatically by mutating methods

Open JamesWrigley opened this issue 2 months ago • 9 comments

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
Image

I'd expect mutating methods to behave like their non-mutating counterparts and add a label.

JamesWrigley avatar Sep 15 '25 15:09 JamesWrigley

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

tiemvanderdeure avatar Sep 15 '25 15:09 tiemvanderdeure

Then why does lines() show it automatically?

lines(rand(X(50)); label="Foo")
Image

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
Image

JamesWrigley avatar Sep 15 '25 16:09 JamesWrigley

Yeah this is why we shouldn't do it by default 🤷

asinghvi17 avatar Sep 15 '25 18:09 asinghvi17

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)

rafaqz avatar Sep 16 '25 01:09 rafaqz

So the real issue is that lines(rand(X(50)); label="Foo") already shows the legend.

Compare to lines(rand(50); label = "Foo"):

Image

tiemvanderdeure avatar Sep 16 '25 08:09 tiemvanderdeure

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.

asinghvi17 avatar Sep 16 '25 08:09 asinghvi17

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.

rafaqz avatar Sep 16 '25 08:09 rafaqz

The relevant Makie issue to push for is https://github.com/MakieOrg/Makie.jl/issues/3207

felixcremer avatar Sep 16 '25 10:09 felixcremer

Haha I even forgot I made that issue.

rafaqz avatar Sep 16 '25 11:09 rafaqz