Re: [R] ggplot2: using more than 6 symbols

From: hadley wickham <>
Date: Mon, 17 Nov 2008 07:00:50 -0600

Hi Dave,

On Mon, Nov 17, 2008 at 6:35 AM, Dave Murray-Rust <> wrote:
> I'm trying to plot multiple lines using different colours/symbols to
> distinguish them. If I try to plot more than 6 lines, I get an error:
>> ggplot( dat, aes(x=time,y=value,group=variable,shape=variable) ) +
>> geom_line()
> Error: scale_shape can deal with a maximum of 6 discrete values, but you
> have 9. See ?scale_manual for a possible alternative
> I find this slightly confusing, as there are ~25 symbols listed for use.
> (I'm using ggplot2 0.7, on OSX, R 2.7.2)

But distinguishing between more than 6 of is very difficult!

> Ideally, I'd like to use a combination of colours and symbols (e.g. 5
> colours and 4 symbols -> 20 unique possibilities) or even colours, symbols
> and linetypes - is there a way to do this in ggplot2?

Unfortunately not - this type of combined scale is on my to do list, but I haven't got around to it yet. Here's a work around:

df <- data.frame(a = 1:20, b = 1:20, c = letters[1:20]) qplot(a, b, data = df, colour = c)

df$d <- factor(rep(1:5, each = 4))
df$e <- factor(rep(1:4, by = 5))

qplot(a, b, data = df, colour = d, shape = e)

Generally, I'd wouldn't advise splitting up a single variable across two aesthetics like this: perceptually I don't think its a great idea.




______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 17 Nov 2008 - 13:04:36 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 17 Nov 2008 - 17:30:25 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive