Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R ggplot2:图形底部的正态分布曲线-geom_text()+;geom_历史图()_R_Ggplot2 - Fatal编程技术网

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谢谢您提供的信息!将在可用时添加为答案。