AlgebraOfGraphics.jl
AlgebraOfGraphics.jl copied to clipboard
Legend doesn't show attributes passed directly to `Visual`
Not quite sure how to describe this, but I get
using AlgebraOfGraphics # v0.6.12
using CairoMakie # v0.8.13
function mwe()
df = DataFrame(:x => rand(5), :y => rand(5), :group => [true, true, false, false, false])
plt = AlgebraOfGraphics.data(df) * mapping(:x, :y; color=:group) * visual(Scatter; marker=:star5, markersize=15)
return draw(plt)
end
mwe()
The issue is the legend has circles instead of stars. (This is more confusing when this is part of a more complicated plot, with multiple legends & shapes being used for other stuff elsewhere).
Also, you can't really see it from this example but the legend also has the wrong marker size (it looks OK bc stars are smaller than circles).
Here is the gross workaround I am currently using:
function workaround()
df = DataFrame(:x => rand(5), :y => rand(5), :group => [true, true, false, false, false])
plt = AlgebraOfGraphics.data(df) * mapping(:x, :y; color=:group) * visual(Scatter; marker=:star5, markersize=15)
fig = Figure()
ax = Axis(fig[1,1])
grid = AlgebraOfGraphics.draw!(ax, plt)
legend = AlgebraOfGraphics.compute_legend(grid)
elts = legend[1][1]
for elt in elts
e = elt[1]
e.attributes.attributes[:marker] = :star5
e.attributes.attributes[:markersize] = 15
end
Legend(fig[1, 2], legend...)
return fig
end
