This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Maping size and fill to data values through aes (ggplot2)

Hi all!

I want to map size and fill to columns of my dataframe but I cant get the fill working. Thanks.

library(ggplot2)
a= data.frame(matrix(rnorm(24),6))
ggplot(a, (aes (X1,X2, size=X3,fill= X4)))+ geom_point()+coord_flip()+scale_fill_gradientn(colours = c('blue', 'red'), values=c(0, 1))
ggplot2 scale_fill_gradientn

1 answer

scale_color_gradientn does the work.

You found the solution at the same time as posting the question?

Yes! After a lot of struggling. the scale_fill_* is used in bargraphs and I was stuck to that + aes (, fill=) instead of aes(, color=)

Log in to answer this question.