[英]Histogram with Known Density using ggplot2 - R
I have a vector of data with random variable values and another vector with the respective probabilities. 我有一个带有随机变量值的数据向量,另一个具有相应概率的向量。 Is there a known function which cleverly draws the histogram or approximate density function? 是否有一个已知函数可以巧妙地绘制直方图或近似密度函数? Doing simple line plots is not always very informative due to outlier data and/or a concentration of points around some value. 由于存在异常数据和/或一些值附近的点集中,因此进行简单的线图绘制并不总是很有帮助。 Thanks. 谢谢。
EDIT: I would like to use ggplot2. 编辑:我想使用ggplot2。
Here you have an example how you could use ggplot2
to make a histogram, density or both. 这里有一个示例,说明如何使用ggplot2
制作直方图和/或密度。
library(ggplot2)
ggplot(data = iris, aes(x = Sepal.Length)) +
geom_histogram()
ggplot(data = iris, aes(x = Sepal.Length)) +
geom_density(colour = '#BD1515', fill = '#BD1515', alpha = 0.2)
ggplot(data = iris, aes(x = Sepal.Length, y = ..density..)) +
geom_histogram(fill = '#CF3030') +
geom_density(colour = '#BD1515', fill = '#BD1515', alpha = 0.35)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.