小编wan*_*m -的帖子

绘制百分比而不是密度

我试图用百分比来模拟密度图,但不幸的是很难找到正确的格式。我提供了下面的代码,尝试使用百分比来模拟密度图。

p <- 
  ggplot(mtcars, aes(x=mpg, y = ..count../sum(..count..))) + 
   #geom_density() alpha=.4, stat = 'bin', binwidth = "3000", position = "identity", fill="grey",cex = 0.8) + 
  geom_histogram(aes(x=mpg, y=..count../sum(..count..)), colour="black", fill="white", cex = 0.8)+
  #geom_density( stat = "density", position = "identity", fill="grey",cex = 0.8) 
  geom_density(stat = 'bin', position = "identity", fill="grey",cex = 0.8)  

p
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

尝试使箱体的密度与曲率相似。但使用密度,它提供了下图:

在此输入图像描述

任何帮助,将不胜感激。谢谢!

r ggplot2

1
推荐指数
1
解决办法
1646
查看次数

标签 统计

ggplot2 ×1

r ×1