How to use more than 6 shapes in qplot

2,228 views
Skip to first unread message

Mateusz

unread,
Dec 4, 2010, 12:02:07 PM12/4/10
to ggplot2
Hi,

I have 3 treatment levels which I split up by facets and I would like
to plot each individual (subject) with different shape, however
somehow there are only 6 shapes supported and I have 11.

qplot(Time, Measured, data=data, color=factor(Treatment),
shape=factor(Subject), geom=c('smooth','point'),method="lm",
formula="y ~ ns(x,2)", facets= . ~ Treatment)
Error: scale_shape_discrete can deal with a maximum of 6 discrete
values, but you have 11. See ?scale_manual for a possible alternative

I know I can use letters, but I am interested in using 11 shapes like
I simply did before with simple basic plot(...) function from core R
environment.

For those thinking that 11 shapes is hard to interpret - NO. It's
harder to interpret plot with more than 3 colours but more are
supported. Imposing such a limitation is equal to saying to user "we
know better what's good for Your data" which is very bad habit.

PS. I already did try
+ scale_shape_manual(value=letters[1:11]) but it does not solve my
problem, I would prefer shapes which are easier to distinguish. And
how to control size of points/shapes/letters on the plot ?

Thanks in advance,
Mateusz

baptiste auguie

unread,
Dec 4, 2010, 12:29:04 PM12/4/10
to Mateusz, ggplot2
Hi,

You can still use the same basic shapes than in base R graphics if you want to,


ggplot(diamonds) +
geom_point(aes(x,y, shape=clarity), size=2) +
scale_shape_manual(value=1:8)

HTH,

baptiste

> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>

mateus...@gmail.com

unread,
Dec 4, 2010, 12:52:06 PM12/4/10
to baptiste auguie, ggplot2
Thanks,

I was trying something like that, but obviously I was doing something wrong. Now it works. Thanks a lot.

Now I used:
 qplot(...) + scale_shape_manual(value=1:11) + geom_point(size=2)

I just could not find this information on mailing list and someone with similar problem got replay that he is doing something wrong if he has more than 6 shapes to plot ;)

Thanks one more time.


2010/12/4 baptiste auguie <bapt...@googlemail.com>

Hadley Wickham

unread,
Dec 6, 2010, 1:59:43 PM12/6/10
to Mateusz, ggplot2
> For those thinking that 11 shapes is hard to interpret - NO. It's
> harder to interpret plot with more than 3 colours but more are
> supported. Imposing such a limitation is equal to saying to user "we
> know better what's good for Your data" which is very bad habit.

Unfortunately, that's just not true - it is much easier to tell the
difference between multiple colours than multiple shapes (although
even with more than 6 colours it starts to get hard). ggplot2 does
it's best to help you make good decisions about how you visualise you
data.

Hadley

--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

Reply all
Reply to author
Forward
0 new messages