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

Document how to set alpha values. #225

Closed
lassepe opened this issue Jul 2, 2021 · 12 comments
Closed

Document how to set alpha values. #225

lassepe opened this issue Jul 2, 2021 · 12 comments

Comments

@lassepe
Copy link

lassepe commented Jul 2, 2021

Thank you for this awesome package! I'm a huge fan of grammar of graphics and I'm excited to see a native Julia implementation of this paradigm.

The tutorial and the philosophy pages of the documentation suggest that one can set the transparency of a layer via the alpha keyword of visualize, i.e. something like visualize(Scatter; alpha = 0.5). However, that does not seem to work (anymore?). It is surprisingly hard to figure out what would be the right thing to do to achieve the result.

It would be great if the documentation could be updated in this regard or if the documentation could include a pointer to the relevant information about accepted keyword arguments of visualize (probably pointing to the Makie.jl docs?).

@piever
Copy link
Collaborator

piever commented Jul 6, 2021

visual(Scatter; alpha = 0.5) should work, do you have an example when it doesn't? That being said, alpha is the only attribute that is added compared to Makie. Ideally it should be implemented in Makie, but I guess if that doesn't happen anytime soon one can document it here.

@lassepe
Copy link
Author

lassepe commented Jul 6, 2021

Here is a minimal example that fails to make the scatter points transparent for

using AlgebraOfGraphics: Scatter, data, draw, mapping, visual
import CairoMakie, ElectronDisplay

df = [(; x, y = sin(x)) for x in (-π):0.1:π]
data(df) * mapping(:x, :y) * visual(Scatter; alpha = 0.5) |> draw

Output:
test

Package versions:

  [cbdf2221] AlgebraOfGraphics v0.4.6 `https://github.com/JuliaPlots/AlgebraOfGraphics.jl.git#master`
  [13f3f980] CairoMakie v0.6.2 `https://github.com/JuliaPlots/Makie.jl.git:CairoMakie#master`
  [d872a56f] ElectronDisplay v1.0.1

@piever
Copy link
Collaborator

piever commented Jul 8, 2021

Ah, thanks for reporting that, this is definitely a bug. I think AoG has trouble applying alpha if no explicit color is passed, either via mapping or via visual. You can probably work around it by doing visual(color = :black, alpha = 0.5).

I suspect it's difficult to fix this in general from AoG, it probably needs MakieOrg/Makie.jl#84 for a cleaner solution.

@lassepe
Copy link
Author

lassepe commented Jul 8, 2021

Thank you for the quick response. Setting the color explicitly does the trick. Should I close this issue since it will essentially work once the alpha channel is supported in Makie?

@piever
Copy link
Collaborator

piever commented Jul 9, 2021

I think it's best to keep it open (even if it's not really actionable) as a reminder to update things on this end (remove current partial implementation) once Makie has alpha transparency support.

@ismael-lajaaiti
Copy link

Bump. As this issue has been open for awhile and it is unclear for how long it will stay open, could we add a short note about that in the documentation? So even if the issue isn't fixed, new users won't struggle to find the trick?

@jerlich
Copy link

jerlich commented Jul 21, 2024

alpha is supported in Makie (as of July 2023). Is it an easy fix to pass the alpha on to Makie now?

@vladdez
Copy link

vladdez commented Jan 14, 2025

We tried to use alpha with Polyand it doesn't work, polygones are not transparent:

dat = DataFrame(; rect = [Rect(0, 0, 1, 2), Rect(1, 2, 2, 2)], group = [1, 2])
layer = mapping(color = :group) * (data(dat) * mapping(:rect) * visual(Poly; alpha = 0.5))
draw(layer)

Image
Is it a bug?

@jkrumbiegel
Copy link
Member

Yeah in principle I would expect alpha to be passed on like any other attribute, there's probably some old code left over from when AoG had its own alpha, which now removes it from the list or something.

@jkrumbiegel
Copy link
Member

Ah no it does get passed along, poly doesn't respect alpha in the first place

@jkrumbiegel
Copy link
Member

I think this issue can be closed as it's not a special AoG attribute anymore and the remaining fixes are on Makie's side

@jkrumbiegel
Copy link
Member

MakieOrg/Makie.jl#4614

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

6 participants