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 disappears when adding plot into Makie figure #578

Closed
stelmo opened this issue Nov 13, 2024 · 2 comments
Closed

Legend disappears when adding plot into Makie figure #578

stelmo opened this issue Nov 13, 2024 · 2 comments

Comments

@stelmo
Copy link

stelmo commented Nov 13, 2024

Hi,

It looks like the legend is dropped when you embed an AoG plot into a Makie figure. See the example below:

using AlgebraOfGraphics, CairoMakie, DataFrames

df = DataFrame(X = rand(1:3, 100), Y = rand(100), G = rand(["1", "2"], 100))

plt = data(df) * visual(Violin) * mapping(:X, :Y, color=:G, side=:G)
draw(plt)

Image

fig = Figure()
draw!(fig[1,1], plt)
fig

Image

@jkrumbiegel
Copy link
Member

That's the documented behavior, you have to call legend! with the output of draw! to place the legend manually. It's assumed that in a larger figure you might want to put it somewhere else than usual.

@stelmo
Copy link
Author

stelmo commented Nov 15, 2024

Ah okay, thanks for clearing it up! I just found it in the docs 😳 In case someone else lands here: https://aog.makie.org/stable/gallery/gallery/customization/legend/

@stelmo stelmo closed this as completed Nov 15, 2024
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

No branches or pull requests

2 participants