Skip to content
Prev 387378 / 398502 Next

Gradient plots in ggplot2

Hi Phillip.

You could try some transformations of your data. Either directly in
scale_fill_gradient or in original data. log transition would be OK but not
with negative data. You could play with some transitions from scales
package. I think that you could also use rescaler function, but I do not
know how.

ggplot(df,aes(x=a,y=c,fill=b))+
   geom_tile()+
   geom_text(label=paste0(round(b,1),"%"),
     size=10,colour="gold")+
   scale_fill_gradient(low="red",high="blue",na.value="grey50", trans="log")

Cheers.
Petr