r - 将相同的密度曲线添加到 R 中的绘图
问题描述
我想知道如何将相同的密度曲线添加到 R 中的xyplot()
fromlattice
包中(请参阅下面的可重现代码)?
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))
推荐阅读
- kubernetes - 在非 AWS Kubernetes 集群上使用 aws-virtual-gpu-device-plugin
- android - Android 11位置权限弹出,用户点击“仅这一次”选项时,为什么操作系统不再询问权限
- typescript - 有没有办法在以下打字稿代码中写单行?
- python - 错误:方法获取不允许用于 url scrapy
- c++ - 使用类型特征来检测是否传递了数组(或指针)
- python - 按行处理 xml db 导出
- knockout.js - 页面加载后渲染同一个淘汰组件的多个实例
- ruby-on-rails - 根据行值对一列进行唯一验证,并以第二列为条件
- java - 如何在android java中保存另一个活动的背景颜色
- yup - 如何使用 YUP 中的验证器 #1 或验证器 #2 检查字段是否有效