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

Add doc example of transparency with Geom.ribbon #1126

Closed
IgorDouven opened this issue Apr 2, 2018 · 10 comments · Fixed by #1175
Closed

Add doc example of transparency with Geom.ribbon #1126

IgorDouven opened this issue Apr 2, 2018 · 10 comments · Fixed by #1175

Comments

@IgorDouven
Copy link

IgorDouven commented Apr 2, 2018

According to the documentation, it should be possible to make Geom.ribbon colors transparent by adding something like Theme(lowlight_opacity=0.3). That does not appear to work however. This would be a great feature to have though.

@bjarthur
Copy link
Member

bjarthur commented Apr 2, 2018

indeed! there is no mention of lowlight_opacity in src/geom/ribbon.jl.

this would be a great first-time contribution. care to take a stab at fixing it? all you would need to do is follow the model here of how to programmatically specify opacity, and apply it here and here.

thanks for filing an issue.

@Mattriks
Copy link
Member

Mattriks commented Apr 2, 2018

From #611 (a workaround for now):

Theme(lowlight_color=c->RGBA{Float32}(c.r, c.g, c.b, 0.2)) 

@IgorDouven
Copy link
Author

@Mattriks Thanks, this worked! (Would be worth adding to the documentation, even if it's only a workaround.)

@bjarthur I'd love to contribute, but this kind of problem is really beyond me (though I'm hoping to get to the point where it wouldn't be).

@bjarthur
Copy link
Member

bjarthur commented Apr 2, 2018

let's leave this open until it's fixed.

@bjarthur bjarthur reopened this Apr 2, 2018
@bjarthur
Copy link
Member

bjarthur commented Apr 3, 2018

thinking on this more...permitting the user to specify both lowlight_opacity and lowlight_color simultaneously would need some special consideration to handle the case where the latter included an alpha channel. so the recommended course of action here i think is to just update the documentation to remove mention of the former and give an example of how to achieve the same effect with the latter.

@Mattriks
Copy link
Member

Mattriks commented Apr 3, 2018

I think fillopacity() will work for only svg e.g. compare

# The plot panel uses fillopacity(Theme.panel_opacity)
p = plot(x=[-2,2], y=[2,-2], 
    Theme(panel_fill=colorant"orange", panel_opacity=0.5)
)
draw(PNG(3.3inch,3.3inch), p)
draw(SVG(3.3inch,3.3inch), p)

whereas the lowlight_color function will work for svg and png.
lowlight_opacity looks like code that someone thought about, but wasn't implemented.

@tlnagy tlnagy changed the title feature request: transparent Geom.ribbon Add doc example of transparency with Geom.ribbon Apr 4, 2018
@tlnagy
Copy link
Member

tlnagy commented Apr 4, 2018

Grepping through the repo for lowlight_opacity only brings up its initialization in theme.jl so it's never used. I'm open to simply removing it (both from the docs and from the source) until we figure out a way to combine it with lowlight_color. It might be nice to throw a depwarn in the meantime.

@Mattriks Mattriks mentioned this issue Jul 14, 2018
4 tasks
@kleinschmidt
Copy link
Contributor

As a general way of combining colors and alphas, why not use Colors.coloralpha? It just sets the alpha of whatever color you pass it, and promotes the type if necessary

julia> using Colors

julia> coloralpha(RGB(0.5, 0.5, 0.5))
RGBA{Float64}(0.5,0.5,0.5,1.0)

julia> coloralpha(RGB(0.5, 0.5, 0.5), 0.7)
RGBA{Float64}(0.5,0.5,0.5,0.7)

julia> coloralpha(RGBA(0.5, 0.5, 0.5, 1.0), 0.7)
RGBA{Float64}(0.5,0.5,0.5,0.7)

julia> c = Lab(RGB(0.2, 0.3, 0.4))
Lab{Float64}(31.579833005156537,-1.8639258539215886,-17.85083480738884)

julia> coloralpha(c, 0.7)
LabA{Float64}(31.579833005156537,-1.8639258539215886,-17.85083480738884,0.7)

That be a good basis for allowing an alpha aes, which I miss from ggplot...

@bjarthur
Copy link
Member

@kleinschmidt have you seen #1175 ?

@Mattriks
Copy link
Member

An alpha aes hopefully will be a future direction in Gadfly. But it would require a much bigger PR involving:

  • implementing alpha as an aesthetic i.e. alpha=:variable
  • Scale.alpha_discrete and Scale.alpha_continuous
  • integration with Guides e.g. Guide.colorkey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants