将相同的密度曲线添加到 R 中的绘图
add the same density curve to a plot in R
我想知道如何将相同的密度曲线添加到 R 中 lattice
包中的 xyplot()
(请参阅下面的可重现代码)?
library(lattice)
xyplot((1:32*.01)~wt|gear , data = mtcars)
lines(density(rnorm(1e3, 3.5))) # add this to all plot panes in `xyplot` above
我们可以使用 layer
library(lattice)
library(latticeExtra)
foo <- xyplot((1:32*.01)~wt|gear , data = mtcars)
foo +
layer(panel.densityplot(rnorm(1e3, 3.5), plot.points = FALSE))
我想知道如何将相同的密度曲线添加到 R 中 lattice
包中的 xyplot()
(请参阅下面的可重现代码)?
library(lattice)
xyplot((1:32*.01)~wt|gear , data = mtcars)
lines(density(rnorm(1e3, 3.5))) # add this to all plot panes in `xyplot` above
我们可以使用 layer
library(lattice)
library(latticeExtra)
foo <- xyplot((1:32*.01)~wt|gear , data = mtcars)
foo +
layer(panel.densityplot(rnorm(1e3, 3.5), plot.points = FALSE))