1
我想向我的圖表添加正態分佈線。但由於某種原因,它底部會變得平坦。ggplot2:在圖形底部的正態分佈曲線 - geom_text()+ geom_historigram()
我的代碼
MyChart <- function(x) {
ggplot(x, aes(x = max.DrawD, y = cum.Return, label = Symbol)) +
scale_y_continuous(breaks = c(seq(0, 10, 1)), limits = c(0,10)) + # outliers excluded
scale_x_continuous(limit =c(0, 0.5)) +
geom_histogram(aes(y = ..density..), binwidth = 0.02) +
geom_text(size = 3) +
stat_function(fun = dnorm, colour = 'firebrick') +
theme_classic()
}
正如你可以看到,紅線(我stat_function()
代碼)是正確的,在圖的底部。我該如何解決這個問題?
謝謝你的信息!當可用時將添加爲答案。 – uncool