Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing plotting symbol for geom_point when using shape

Tags:

r

ggplot2

I must be obviously missing something simple, or this is a small bug. The geom_point () is always missing a plotting symbol when the shape=factor is used. This does not happen when color=factor is used. Appreciate your help. Here is a test code.

test <- data.frame(let=sample(LETTERS,7), id=c(1:7), y=c(id*7))

ggplot(data=test, aes(x=id, y=y))+
geom_point(aes(shape=let), size=6)

"Notice here the missing point (only 6 out 7) as one of the symbol is missing, which usually is alphabetically the last factor"

ggplot(data=test, aes(x=id, y=y))+
geom_point(aes(color=let), size=6)

"Here we see 7 points with different colors"

Thanks, VJ

like image 343
Vijay Ivaturi Avatar asked Oct 28 '25 13:10

Vijay Ivaturi


1 Answers

That's because scales::shape_pal defines a maximum of 6 values; try adding scale_shape_manual(values=1:7)

like image 91
baptiste Avatar answered Oct 30 '25 07:10

baptiste