为R中的多个图着色曲线下的区域
coloring the area under a curve for multiple plots in R
我想知道我是否可以颜色我下面图中相同曲线下的区域?
library(lattice)
library(latticeExtra)
foo <- xyplot((1:32*.01)~wt|gear , data = mtcars)
foo +
layer(panel.densityplot(rnorm(1e3, 3.5), plot.points = FALSE))
# By color I mean like so:
d <- density(rnorm(1e3, 3.5));
plot(d, type = 'n');
polygon(d, col = 2)
我们可以使用
library(lattice)
library(latticeExtra)
d <- density(v1)
foo <- xyplot((1:32*.01)~wt|gear , data = mtcars)
foo +
layer(panel.polygon(d, col = 2, alpha = 0.3))
数据
set.seed(24)
v1 <- rnorm(1e3, 3.5)
我想知道我是否可以颜色我下面图中相同曲线下的区域?
library(lattice)
library(latticeExtra)
foo <- xyplot((1:32*.01)~wt|gear , data = mtcars)
foo +
layer(panel.densityplot(rnorm(1e3, 3.5), plot.points = FALSE))
# By color I mean like so:
d <- density(rnorm(1e3, 3.5));
plot(d, type = 'n');
polygon(d, col = 2)
我们可以使用
library(lattice)
library(latticeExtra)
d <- density(v1)
foo <- xyplot((1:32*.01)~wt|gear , data = mtcars)
foo +
layer(panel.polygon(d, col = 2, alpha = 0.3))
数据
set.seed(24)
v1 <- rnorm(1e3, 3.5)