Question

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.

Was it helpful?

Solution

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)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top