On 17 Nov 2008, at 13:00, hadley wickham wrote:

Hi Dave,

On Mon, Nov 17, 2008 at 6:35 AM, Dave Murray-Rust
<[EMAIL PROTECTED]> 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!

Absolutely! But it's easier than between different colours of line, especially given low-quality printer output...

I guess the "correct" answer is that if you're trying to plot more than 6 lines on the graph, you need to rethink the graph.



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)


Ah, thanks for that; I'd been trying something similar, with slightly limited success.



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.

I agree, that is quite confusing - a combined scale would definitely be more clear.

Thanks for the info!

Cheers,
dave

--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to