geom_tile single color as 0, then color scale

前端 未结 1 861
轻奢々
轻奢々 2021-02-04 09:29

I want to produce a heat map where with a color pallet of green to red, but values of 0 are in white. I got started with geom_tile heatmap with different high fill colours based

1条回答
  •  野的像风
    2021-02-04 10:17

    You can use scale_fill_gradientn():

    ggplot(df,aes(x = Var1,y = Var2, fill = z)) + 
      geom_tile() + 
      scale_fill_gradientn(colours = c("white", "green", "red"), values = c(0,0.1,1))
    

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