tags:

views:

83

answers:

1

When running this code (go ahead, try it):

library(ggplot2)
(myDat <- data.frame(cbind(VarX=10:1, VarY=runif(10)), 
    Descrip=sample(LETTERS[1:3], 10, replace=TRUE)))
ggplot(myDat,aes(VarX,VarY,shape=Descrip,size=3)) + geom_point()

... the "size=3" statement does correctly set the point size. However it causes the legend to give birth to a little legend beneath it, entitled "3" and containing nothing but a big dot and the number 3.

This does the same

ggplot(myDat,aes(VarX,VarY,shape=Descrip)) + geom_point(aes(size=3)) 

Yes, it is funny. It would have driven me insane a couple hours ago if it weren't so funny. But now let's make it stop.

+5  A: 

That's because it's interpreting it as an aesthetic mapping rather than a constant. This works I think:

ggplot(myDat,aes(VarX,VarY,shape=Descrip)) + geom_point(size=3)
Jonathan Chang
Learning the difference between the data-mapped aesthetics of aes() and the constants outside of aes() makes ggplot so much easier.
Matt Parker