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

transparency affects color key #1531

Closed
IgorDouven opened this issue Apr 11, 2021 · 2 comments
Closed

transparency affects color key #1531

IgorDouven opened this issue Apr 11, 2021 · 2 comments

Comments

@IgorDouven
Copy link

If I add transparency to a plot, it also affects the color key. I cannot find a way to override it. Here is a MWE:

v = randn(1000)
plot(x=v, Stat.density, Geom.polygon(fill=true, preserve_order=true),
    xintercept=[-1, 1],
    Geom.vline(color="MidnightBlue"),
    Guide.manual_color_key("", ["Some interval"], ["rgba(25, 25, 112, 1.)"]),
    Theme(default_color="lightskyblue", line_width=2pt, alphas=[.3]))

The transparency is meant to pertain to the fill. It doesn't pertain to the vlines, but then also shouldn't pertain to the color key, which pertains to the vlines (in actuality I'm showing several intervals).

Also, is there a way to show the vlines 'on top of' the fill? Without the transparency, they would be partly hidden.

@Mattriks
Copy link
Member

Layer order matters, and alphas in Theme affects the colorkey, but alpha in layers does not:

plot(x=v,
    layer(xintercept=[-1, 1], Geom.vline(color="MidnightBlue")),
    layer(Stat.density, Geom.polygon(fill=true, preserve_order=true), alpha=[.3]),
    Guide.manual_color_key("", ["Some interval"], ["rgba(25, 25, 112, 1.)"]),
    Theme(default_color="lightskyblue", line_width=2pt)
)

The bit about layer order is in the Gadfly docs (at the bottom of page).

@IgorDouven
Copy link
Author

Thank you, and sorry for overlooking this in the documentation.

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