Remove grey fill for out of bounds values when using limits in scale_

后端 未结 1 1456
误落风尘
误落风尘 2021-01-19 14:07

I am using R (3.0.1) and ggplot2 (ggplot2_0.9.3.1) with geom_tile and scale_fill_gradient. I am using the \'limits\' opti

1条回答
  •  别那么骄傲
    2021-01-19 14:32

    Add the argument na.value="transparent" to scale_fill_gradient:

    p + theme_bw() + geom_tile(aes(fill=z)) +
         scale_fill_gradient(low="green", high="red",
                             limits=c(-0.1, 0.1), na.value="transparent")
    

    enter image description here

    0 讨论(0)
提交回复
热议问题