我想绘制直方图。我还希望在y轴上具有密度而不是频率。
我能够创建直方图,但是y轴没有更改为密度。
你能帮我吗?
最好的问候, Dipen Bista
test=data.frame(c(0.17,0.39,0.24,0.24,0.17,0.42,0.33,0.25,0.36,0.26,0.24,0.16))
names(test) = 'ratio'
ggplot(data=test,aes(x=test$ratio,y=..density..)) +
geom_histogram(breaks=seq(0.1,0.5, by=0.1),
col="black",
fill="light gray",
alpha=.8)+
labs(title="Histogram of Length ratio")+
labs(x='Angle',y='Density')+
theme_bw()
答案 0 :(得分:0)
library(ggplot2)
test = data.frame(c(0.17,0.39,0.24,0.24,0.17,0.42,0.33,0.25,0.36,0.26,0.24,0.16))
ggplot(test, aes(x = test$ratio)) +
geom_density()