【问题标题】:Merging or overlaying xyplots in a lattice panel在格子面板中合并或覆盖 xyplots
【发布时间】: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


    【解决方案1】:

    我想你正在寻找as.layer;尝试这个。它也在latticeExtra 库中。

    library(latticeExtra)
    a + as.layer(b)
    

    在此处查看文档:http://latticeextra.r-forge.r-project.org/#as.layer

    【讨论】:

      猜你喜欢
      • 2012-04-04
      • 2012-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      • 2011-12-05
      • 2015-01-23
      相关资源
      最近更新 更多