【问题标题】:coloring the area under a curve for multiple plots in R为R中的多个图着色曲线下的区域
【发布时间】:2020-08-21 22:36:34
【问题描述】:

我想知道是否可以着色下图中相同曲线下的区域?

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)

【问题讨论】:

    标签: r plot lattice


    【解决方案1】:

    我们可以使用

    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)
    

    【讨论】:

    • @Reza。你之前说过你不想要密度内的点?
    • @Reza 你可以。更改alpha
    • 你能看到this follow-up吗?
    猜你喜欢
    • 2023-03-16
    • 1970-01-01
    • 2012-08-27
    • 1970-01-01
    • 2018-11-01
    • 2021-12-29
    • 1970-01-01
    • 2012-04-20
    相关资源
    最近更新 更多