【发布时间】:2013-10-31 22:49:43
【问题描述】:
试图弄清楚如何在创建现有格子面板后向其添加点或数据系列。这是否与 plot.points 和/或更新功能有关?
# Initialize first plot
library(lattice)
a <- xyplot(Sepal.Length~Sepal.Width, groups=Species, data=iris
, subset=Species %in% levels(Species)[1:2])
print(a)
# Create second plot to overlay or merge with the first plot
b <- xyplot(Sepal.Length~Sepal.Width, groups=Species, data=iris
, subset=Species %in% levels(Species)[3])
# Initial attempt at merging plots:
library(latticeExtra)
print(c(a,b)) # this displays the data in an adjacent second panel
print(c(a,b,layout=c(1,1))) # and this only shows series "b"
注意:在本例中,图“a”和“b”均来自原始 iris 数据框,但理想情况下,该解决方案适用于不同的数据框。
有什么想法吗?
谢谢!
布莱恩
【问题讨论】:
标签: r merge overlay panel lattice