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

后端 未结 2 1018
遇见更好的自我
遇见更好的自我 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:21

    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))))
    

提交回复
热议问题