Hi,
how could I set an aplha value when I'm using scale_fill_gradientn()?
Thank you!
Hi,
how could I set an aplha value when I'm using scale_fill_gradientn()?
Thank you!
library(tidyverse)
ggplot(faithfuld, aes(waiting, eruptions)) +
geom_raster(aes(fill = density)) +
scale_fill_gradientn(colours = terrain.colors(10,alpha=0.5))
... or simply this way, no matter which scale_fill_*
or scale_color_*
function you use:
library(tidyverse)
ggplot(faithfuld, aes(waiting, eruptions)) +
geom_raster(aes(fill = density), alpha = 0.5) +
scale_fill_gradientn(colours = terrain.colors(10))
If you want to have changing alpha values, you map to it inside the aes
as you do with any other aesthetic: geom_tile(aes(fill = density, alpha = x)
.
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.