Here is my data: https://pastebin.com/raw/6QBDEZaF
Here is my code (if you read the above csv file into "data", with a header):
library(ggplot2)
ggplot(data = mydata, aes(d1,d2)) +
geom_raster(aes(fill = ratio), interpolate = FALSE) +
scale_fill_gradientn(
colours = c("black","#dda158","#e2cf83","#8ed1b2","#2faf5c","#08770c"),
values = c(0,0.4,0.45,0.5,0.6,0.8,1)) +
theme_minimal()
This produces a raster plot where the scale blends the colours in both the plot and the legend together. I'd like to use ONLY those 6 colours with no blending in both the plot and the legend, so there are 6 colours and each point is assigned one of those.
I tried binning my data beforehand and then plotting this, but that's very messy to do and doesn't change the legend. I tried using other functions than geom_raster, but none give me the result I want. I know there must be an easy solution, but I can't find it. Thanks a lot.