i want a color scale like in the picture:
So from top to buttom we have:
a very bright yellow (white-ish), orange, red, black, blue, light blue to very bright blue (white-ish)
I want a value of 0 always to be displayed as "black". The smallest (negative) value should be that "extreme bright blue". The biggest value (postive) should be the "extreme bright yelllow".
Please note that the min and max are not equally distant from the origin 0.
Thats where i am:
library(ggplot2)
df <- data.frame(xDim = c(0, 1, 2, 0, 1, 2, 0, 1, 2), yDim = c(2, 2, 2, 1, 1, 1, 0, 0, 0), high = c(0, -1, 6, -3, 8, 5, -2, 7, 5))
ggplot(df, aes(xDim, yDim)) +
geom_raster(aes(fill = high)) +
scale_fill_gradient2(low = "blue", mid = "black", high = "red", midpoint = 0)
scale_fill_gradientn
instead, with appropriate breaks and colors. – Axemanquantile
to set the breaks. Also consider theviridis
color palettes: cran.r-project.org/web/packages/viridis/vignettes/… Some of the palettes seem similar to what you want, and would be a drop intoggplot
withscale_fill_viridis(option="plasma")
. – Eric Watt