如何在R中叠加密度图? [英] How to overlay density plots in R?

查看:16
本文介绍了如何在R中叠加密度图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用 R 在同一台设备上叠加 2 个密度图.我该怎么做?我在网上搜索,但没有找到任何明显的解决方案.

I would like to overlay 2 density plots on the same device with R. How can I do that? I searched the web but I didn't find any obvious solution.

我的想法是从文本文件(列)中读取数据,然后使用

My idea would be to read data from a text file (columns) and then use

plot(density(MyData$Column1))
plot(density(MyData$Column2), add=T)

或者本着这种精神的东西.

Or something in this spirit.

推荐答案

使用 lines 作为第二个:

plot(density(MyData$Column1))
lines(density(MyData$Column2))

不过,请确保第一个图的限制是合适的.

make sure the limits of the first plot are suitable, though.

这篇关于如何在R中叠加密度图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆