简体   繁体   English

使用 ggplot 曲线 geom_line()

[英]Curve geom_line() with ggplot

I used ggplot() and geom-line() as follows我使用ggplot()geom-line()如下

ggplot(tabla3) + geom_line(aes(tabla3$MC, tabla3$Normal), lwd = 1)

Result:结果: 在此处输入图像描述

But I want it to look like this:但我希望它看起来像这样:

在此处输入图像描述

If you know the mean and standard deviation of your data, why not just plot a normal distribution?如果您知道数据的均值和标准差,为什么不只是 plot 一个正态分布?

x <- seq(50, 90, length=101)
hx <- dnorm(x, mean(x), sd(x))

plot(x, hx, type = 'l')

ggplot version ggplot 版本

ggplot(data = tibble(x), aes(x)) +
  stat_function(fun = dnorm, n = 101, args = list(mean = mean(x), sd = sd(x))) + ylab("") +
  scale_y_continuous(breaks = NULL)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM