ggplot Poisson density curve: why zigzag lines?

巧了我就是萌 提交于 2019-12-07 11:19:48

问题


I would like to plot the density function of a Poisson distribution. I am not sure why I get a jaggy line (in blue). On the sample plot, the normal density curve (in red) looks smooth. It is because the reason the Poisson density function doesn't accept decimal values? How to eliminate the zigzag in the Poisson density plot? Thanks very much for any help.

library(ggplot2)
ggplot(data.frame(X = seq(5, 30)), aes(x = X)) +
  stat_function(fun=dpois, geom="line", size=2, color="blue3", args =  list(lambda = 15)) +
  stat_function(fun=dnorm, geom="line", size=2, color="red4", args = list(mean=20, sd=2))

来源:https://stackoverflow.com/questions/28073783/ggplot-poisson-density-curve-why-zigzag-lines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!