從埃裏克森的回答中的數據,你也可以看看格子包,應該已經與R安裝過程中安裝:
library(lattice)
# Each group in a separate mini plot
xyplot(y ~ x | group, data = dat)
# All groups in one plot, different colors for each group
# Not at all interesting with the example data you've provided
xyplot(y ~ x, groups=dat$group, data = dat)
這裏的每一個小的例子位更多的數據:
set.seed(1)
mydf <- data.frame(
group = sample(letters[1:4], 50, replace = TRUE),
x = runif(50, 0, 7),
y = runif(50, 0, 7)
)
xyplot(y ~ x, groups=mydf$group, data = mydf,
auto.key = list(corner = c(0, .98)), cex = 1.5)
xyplot(y ~ x | group, data = mydf,
auto.key = list(corner = c(0, .98)), cex = 1.5)