I would like to increase the range of values in the graph. In the example, the values range from 50 to 200. However, I need to distribute the values as follows: 50 75 100 125 150 175 200 and preferably using the scale_fill_gradientn
function, is it possible?
volcano %>% reshape2::melt(varnames=c("x", "y")) %>% as_tibble() %>%
ggplot(aes(x,y, fill=value)) geom_tile()
scale_fill_gradientn(colours=hcl.colors(15, palette = "Purple-Green"), limits=c(50,200))
CodePudding user response:
We could use breaks
along with labels
argument:
library(ggplot2)
volcano %>% reshape2::melt(varnames=c("x", "y")) %>% as_tibble() %>%
ggplot(aes(x,y, fill=value)) geom_tile()
scale_fill_gradientn(colours=hcl.colors(15, palette = "Purple-Green"), limits=c(50,200),
breaks = c(50,75,100,125, 150, 175, 200), labels=c(50,75,100,125, 150, 175, 200))