mjskay / ggdist

Visualizations of distributions and uncertainty
https://mjskay.github.io/ggdist/
GNU General Public License v3.0
854 stars 26 forks source link

Create custom scales / aesthetics for lineribbons #40

Open mjskay opened 5 years ago

mjskay commented 5 years ago

including:

ASKurz commented 4 years ago

Just ran into this problem. I'd like to set ribbon fill, but not the line, semitransparent. Is there a current workaround for this?

mjskay commented 4 years ago

The simplest workaround would probably be to disable the line (color = NA) and then draw the line as a separate geom. That, or you could try assigning a fill color that has an alpha component to it (not 100% sure that would work)

ASKurz commented 4 years ago

Got it. After playing around, this works:

data %>% 
  ggplot(aes(x = x, y = Estimate, ymin = Q2.5, ymax = Q97.5,
             fill = condition, color = condition)) +
  geom_lineribbon() +
  scale_fill_viridis_d(alpha = 1/2) +
  scale_color_viridis_d()
mjskay commented 4 years ago

Awesome! Had no idea the color scales had an alpha argument, that's very useful!