R ggplot2:图形底部的正态分布曲线-geom_text()+;geom_历史图()
我正试图在图表中添加一条正态分布线。但由于某种原因,它的底部变得平坦 我的代码R ggplot2:图形底部的正态分布曲线-geom_text()+;geom_历史图(),r,ggplot2,R,Ggplot2,我正试图在图表中添加一条正态分布线。但由于某种原因,它的底部变得平坦 我的代码 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(
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()
}
MyChart更新:所以我解决了它。但我不知道为什么它现在起作用了。刚刚添加了一个关于平均值和标准偏差的手动规范
更新代码
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, args = list(mean = mean(x$max.DrawD), sd = sd(x$max.DrawD)), colour = 'firebrick') +
theme_classic()
}
MyChart谢谢您提供的信息!将在可用时添加为答案。