R ggplot2 - How do I specify out of bounds values' colour

后端 未结 2 1015
遇见更好的自我
遇见更好的自我 2020-11-30 04:40

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

2条回答
  •  [愿得一人]
    2020-11-30 05:36

    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)
    

提交回复
热议问题