我试图用百分比来模拟密度图,但不幸的是很难找到正确的格式。我提供了下面的代码,尝试使用百分比来模拟密度图。
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)
尝试使箱体的密度与曲率相似。但使用密度,它提供了下图:
任何帮助,将不胜感激。谢谢!