![](/img/trans.png)
[英]Set different color line for mean and quantile in geom density ridges plot
[英]Histogram, Density Plot, Quantile Line
我有一個返回序列,已經繪制了直方圖,但是我需要為此添加密度曲線和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)
嘗試這個:
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")
希望能幫助到你
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.