R 在晶格面板中合并或覆盖XYPLOT

R 在晶格面板中合并或覆盖XYPLOT,r,merge,overlay,panel,lattice,R,Merge,Overlay,Panel,Lattice,尝试了解如何在创建现有晶格面板后向其添加点或数据系列。这是否与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

尝试了解如何在创建现有晶格面板后向其添加点或数据系列。这是否与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我想您正在寻找
as.layer
;试试这个。它也在
latticecextra
库中

library(latticeExtra)
a + as.layer(b)
请参阅此处的文档: