[R] Overplotting: plot() invocation looks ugly ... suggestions?

hadley wickham h.wickham at gmail.com
Wed Jul 26 09:54:17 CEST 2006


> And if lattice is ok then try this:
>
> library(lattice)
> xyplot(Consumption ~ Quarter, group = Year, data, type = "o")

Or you can use ggplot:

install.packages("ggplot")
library(ggplot)
qplot(Quarter, Consumption, data=data,type=c("point","line"), id=data$Year)

Unfortunately this has uncovered a couple of small bugs for me to fix
(no automatic legend, and have to specify the data frame explicitly)

The slighly more verbose example below shows you what it should look like.

data$Year <- factor(data$Year)
p <- ggplot(data, aes=list(x=Quarter, y=Consumption, id=Year, colour=Year))
ggline(ggpoint(p), size=2)

Regards,

Hadley



More information about the R-help mailing list