lattice - plotting more than one data set in R using xyplot -
i'd plot multiple data sets on graph can't figure out how. need put t
, u
, v
, w
on functioning xyplot
.
library(lattice) x <- rnorm(250, 5, .5) y <- rnorm(250, 5, .4) t <- rnorm(200, 6, .7) u <- rnorm(200, 6, .6) v <- rnorm(150, 7, .9) w <- rnorm(150, 7, .8) xyplot(y ~ x, xlab="", ylab="", par.settings = list(axis.line = list(col="transparent")), panel = function(x, y,t,u,...) { panel.xyplot(x, y, col=3, pch=16) panel.rug(x, y, col=8, x.units = rep("snpc", 2), y.units = rep("snpc", 2), ...)})
if you're looking make scatter plot of points coordinates defined (x, y), (t, u), & (v, w), following should work you:
df <- data.frame(v1 = c(x, t, v), v2 = c(y, u, w), v3 = c(rep("xy", length(x)), rep("tu", length(t)), rep("vw", length(v)))) xyplot(v1 ~ v2, group = v3, data = df, xlab="", ylab="", par.settings = list(axis.line = list(col="transparent")), panel = function(x, y, groups...) { panel.xyplot(x, y, col = c("red", "blue", "green"), # change if want other colours pch=16) panel.rug(x, y, col = 8, x.units = rep("snpc", 2), y.units = rep("snpc", 2)) })
if you're looking plot them chart in other way, please clarify in question.
Comments
Post a Comment