Using ggplot2
in R
, I can obtain a discrete color scale like the following:
This can be generated as seen here.
However, it does not look great. I'd like ro remove the spacing between the levels, and I thought that maybe I could switch to a continuous color scale, using scale_gradientn()
and having a very steep gradient between different colors.
This way I could use a continuous color scale, which has labels in the right places and looks great, instead of a discrete one.
However, this is the best I could come up with:
library(ggplot2)
ggplot(faithfuld, aes(waiting, eruptions)) +
geom_raster(aes(fill = density)) +
scale_fill_gradientn(
colours = c("red", "green", "blue", "yellow"),
values=c(0, 0.25, 0.25001, 0.5, 0.5001, 0.75, 0.75001,1)
)
Which clearly is not good enough, as significant color shifting can be seen between the 4 levels.
Is this possible at all in ggplot2?