我有一个回报序列,我已经绘制了直方图,但我需要添加密度曲线和0.05分位线。我该如何简单地做到这一点呢?
我的直方图代码:
ggplot(MyData, aes(x=Returns)) + geom_histogram(binwidth=1, colour="black", fill="white")
我为了添加分位线所做的尝试:
quantile <- quantile(Returns, prob = 0.05)
ggplot(MyData, aes(x=Returns)) + geom_histogram(binwidth=1, colour="black", fill="white") +
geom_vline(aes(xintercept=quantile), color="red", linetype="dashed", size=1)
发布于 2014-10-12 22:58:24
试试这个:
分位线
geom_vline(xintercept=quantile, color="red", linetype="dashed", size=1)
密度
geom_histogram(aes(y=..density..), binwidth=1, colour="black", fill="white") + geom_density(fill=NA, colour="royalblue")
希望能有所帮助
https://stackoverflow.com/questions/26327017
复制相似问题