简体   繁体   English

密度函数图不是真正垂直的 - ggplot2

[英]Density function plot not really vertical - ggplot2

I am plotting a density function with the ggplot2 package. 我正在使用ggplot2包绘制密度函数。 I noticed that the first and second vertical line are not perfectly rectangular, although as far as I understand they should be, or? 我注意到第一条和第二条垂直线不是完全矩形的,虽然据我所知他们应该是,或者? I also found this to be the case, when plotting a distribution of the binomial distribution that the the steps are not really rectangular. 我也发现情况就是这样,当绘制二项分布的分布时,步骤不是真正的矩形。

library(ggplot2)
p_uniform_density <- ggplot(data.frame(x = c(-2, 17.5)), aes(x)) + 
stat_function(fun = dunif, args = list(min = 0, max = 15), size=1.2 ) +
theme_bw() +
labs(y = "f(X)", x = "X") +
theme(text = element_text(size=20) ,  panel.grid.major = element_line(size = 0.2, linetype = 'solid', colour = "grey"), 
    panel.grid.minor = element_line(size = 0.1, linetype = 'solid', colour = "grey")) +
scale_x_continuous( breaks = c(-2:17.5))

具有倾斜的起始值和结束值的密度图

尝试使用n=1e3中的n=1e3 stat_function

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

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