| Lattice code |
ggplot code |
xyplot(rating ~ year, data=movies)
|
qplot(year, rating, data=movies), or
ggpoint(ggplot(movies, aes=list(x=year, y=rating)))
|
xyplot(rating ~ year | Comedy + Action, data=movies)
|
qplot(year, rating, Comedy ~ Action, data=movies) or
qplot(year, rating, . ~ Action + Comedy, data=movies) or
qplot(year, rating, Comedy + Action ~ . , data=movies)
depending on what you want to compare
|
xyplot(rating ~ year, data=movies)
|
qplot(year, rating, data=movies)
|
stripplot(~ rating , data=movies, jitter.data = TRUE)
|
qplot(rating, 1, data=movies, type="jitter")
|
bwplot(Comedy ~ rating ,data=movies)
|
qplot(factor(Comedy), rating, data=movies, type="boxplot")
|
xyplot(wt ~ mpg, mtcars, type=c("p","smooth"))
|
qplot(mpg, wt, data=mtcars, type=c("point","smooth"))
|
xyplot(wt ~ mpg, mtcars, type=c("p","r"))
|
qplot(mpg, wt, data=mtcars, type=c("point","smooth"), method=lm)
|
xyplot(wt ~ mpg | cyl, mtcars, scales=list(y=list(relation="free")))
|
Currently not possible in ggplot |
xyplot(wt ~ mpg, mtcars, group=cyl, auto.key=TRUE)
|
Map directly to an aesthetic like colour, size, or shape.
qplot(mpg, wt, data=mtcars, col=cyl)
|
xyplot(wt ~ mpg, mtcars, xlim=c(20,30))
|
Works like lattice, except you can't currently specify a different limit for each panel/facet
qplot(mpg, wt, data=mtcars, xlim=c(20,30))
|
xyplot(wt ~ mpg, mtcars, xlab="Miles per gallon", ylab="Weight", main="Weight-efficiency tradeoff")
|
qplot(mpg, wt, data=mtcars, xlab="Miles per gallon", ylab="Weight", main="Weight-efficiency tradeoff")
|
xyplot(wt ~ mpg, mtcars, aspect=1)
|
p <- qplot(mpg, wt, data=mtcars)
(p$aspect <-1)
|
par.settings, and trellis.options.set
|
See ?ggopt for a few equivalents |
trellis.par.get
|
ggopt
|