I want to plot a variable on a map, showing positive values in green and negative values in red.
I'm using ggplot2. First, I used this command :
scale_fill_gradient2(low="red",mid="white",high="green")
I obtained this result:
But I don't like the result. Most values are around 0, and the scale doesn't separate well these values : they are all white. So, I want to modify the scale, in order to show more diversity among values close to 0. In the ggplot2 scale documentation, there is an argument allowing to do that : values. But, this argument is working with scale_fill_gradientn, and not scale_fill_gradient2. So, I used this new function :
scale_fill_gradientn(colours = c("red", "white", "green"),
values = scales::rescale(c(-1, -0.2, 0, 0.2, 1)))
Now it's better ! But there is one problem : the center of the scale (white colour) is no longer 0, it's around 5. And I don't know how to change that, because low/mid/high arguments I used in the previous plot are not working in scale_fill_gradientn function.. So my question is : how to use both mid and values arguments, in order to make a personalized scale in ggplot ?