In the plot generated by the following code I would like to alter the colours so that all values < 0.6 are the same as the \"low\" colour and all values greater than 1 ar
Try changing geom_tile
to below:
geom_tile(aes(fill = ifelse(value<0.6,min(m$value,na.rm=TRUE),
ifelse(value>1,max(m$value,na.rm=TRUE),
value))))
EDIT: Then don't use min max, so we will get 0.6-1 range:
geom_tile(aes(fill = ifelse(value<0.6,0.6,
ifelse(value>1,1,
value))))
As you said youself, you want the oob
argument in the scale_fill_gradient
. To clamp values, you can use squish from the scales package (scales
is installed when ggplot2
is installed):
library(scales)
and later
scale_fill_gradient(low = "red", high = "green", limits=c(0.6, 1), oob=squish)