我想在这张图上绘制多个数据集,但我无法弄清楚如何。
我需要将t
,u
,v
,w
放在已经正常运作的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), ...)})
答案 0 :(得分:0)
如果您要制作坐标由(x,y),(t,u)和&amp;所定义的点的散点图。 (v,w),以下内容适合您:
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 this if you want other colours
pch=16)
panel.rug(x, y, col = 8, x.units = rep("snpc", 2), y.units = rep("snpc", 2))
})
如果您希望以其他方式将它们绘制到图表中,请在您的问题中说明。