多边形函数创建奇怪的形状

Polygon function creates strange shape

我正在尝试在同一个地块上绘制多个分布。出于某种原因,当我使用多边形函数时,它没有位于 x 轴上,而是开始悬浮。

感谢您提供有关如何阻止此问题的任何建议!

x <- seq(0,5,length=1000) 
plot(x = x,                   
     y = dnorm(x, 1.5, 0.4),                  
     type = "l",     
     col = "white",
     axes = FALSE,
     mgp = c(2, 2, 2), 
     ylim=c(0,2),                         # Set limit of y-axis
     frame.plot=TRUE, 
     xlab = "theta",                         
     ylab = "plausibility",
     font.main = 1,
     main=paste("Distributions"),
     lwd=2
)      
polygon(x,dnorm(x, 1.5, 0.4),col=1,border = NULL) 
polygon(x,dnorm(x, 1, 0.5),col=2,border = NULL) 

?polygon 的文档所述

x, y vectors containing the coordinates of the vertices of the polygon.

我们必须将 0 作为顶点添加到 xy 坐标。

polygon(x=c(0, x), y=c(0, dnorm(x, 1.5, 0.4)), col=1, border=NULL) 
polygon(x=c(0, x), y=c(0, dnorm(x, 1, 0.5)), col=2, border=NULL) 

结果