Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legend doesn't show attributes passed directly to Visual #434

Closed
ericphanson opened this issue Nov 3, 2022 · 0 comments · Fixed by #505
Closed

Legend doesn't show attributes passed directly to Visual #434

ericphanson opened this issue Nov 3, 2022 · 0 comments · Fixed by #505

Comments

@ericphanson
Copy link

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()

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

workaround

@jkrumbiegel jkrumbiegel linked a pull request Jul 16, 2024 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant