11

作成された既存の格子パネルにポイントまたはデータ シリーズを追加する方法を見つけようとしています。これは、plot.points および/または update 関数と関係がありますか?

# 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データフレームから取得されていますが、理想的には、ソリューションは個別のデータフレームで機能します。

何か案は?ありがとう!
ブライアン

4

1 に答える 1

20

を探しているas.layerと思います。これを試して。latticeExtra図書館にもあります。

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

こちらのドキュメントを参照してください: http://latticeextra.r-forge.r-project.org/#as.layer

于 2013-10-22T21:23:54.077 に答える