在同一个 y 轴上叠加三个曲线
Overlay three curves in the same y axis
我想用三个不同的 sigma 值叠加正态分布的三个曲线。我这样做了:
curve(dnorm(x, mean(x), sd(x)), col = 2, lwd = 2)
par(new = TRUE)
curve(dnorm(x, mean(x), sd(x)/2), col = 3, lwd = 2)
par(new = TRUE)
curve(dnorm(x, mean(x), sd(x)*2), col = 4, lwd = 2)
结果是
但我只想使用一个 y 轴刻度,所以这三个图是一个在另一个下面,而不是在同一个 y 轴上。另外我想扩大x轴的范围,例如从-3到3
首先通过设置plot
参数type = "n"
打开一个空白图形设备。然后add = TRUE
3条曲线。
plot(c(0, 1), c(0, 3), type = "n", xlab = "", ylab = "")
curve(dnorm(x, mean(x), sd(x)), col = 2, lwd = 2, add = TRUE)
curve(dnorm(x, mean(x), sd(x)/2), col = 3, lwd = 2, add = TRUE)
curve(dnorm(x, mean(x), sd(x)*2), col = 4, lwd = 2, add = TRUE)
您可以使用 yaxt
和 xaxt
从图表中删除 y 轴。
curve(dnorm(x, mean(x), sd(x)), col = 2, lwd = 2,ylab="My y axis name")
par(new = TRUE)
curve(dnorm(x, mean(x), sd(x)/2), col = 3, lwd = 2,yaxt='n',xaxt='n',ylab="")
par(new = TRUE)
curve(dnorm(x, mean(x), sd(x)*2), col = 4, lwd = 2,yaxt='n',xaxt='n',ylab="")
给予,
我想用三个不同的 sigma 值叠加正态分布的三个曲线。我这样做了:
curve(dnorm(x, mean(x), sd(x)), col = 2, lwd = 2)
par(new = TRUE)
curve(dnorm(x, mean(x), sd(x)/2), col = 3, lwd = 2)
par(new = TRUE)
curve(dnorm(x, mean(x), sd(x)*2), col = 4, lwd = 2)
结果是
首先通过设置plot
参数type = "n"
打开一个空白图形设备。然后add = TRUE
3条曲线。
plot(c(0, 1), c(0, 3), type = "n", xlab = "", ylab = "")
curve(dnorm(x, mean(x), sd(x)), col = 2, lwd = 2, add = TRUE)
curve(dnorm(x, mean(x), sd(x)/2), col = 3, lwd = 2, add = TRUE)
curve(dnorm(x, mean(x), sd(x)*2), col = 4, lwd = 2, add = TRUE)
您可以使用 yaxt
和 xaxt
从图表中删除 y 轴。
curve(dnorm(x, mean(x), sd(x)), col = 2, lwd = 2,ylab="My y axis name")
par(new = TRUE)
curve(dnorm(x, mean(x), sd(x)/2), col = 3, lwd = 2,yaxt='n',xaxt='n',ylab="")
par(new = TRUE)
curve(dnorm(x, mean(x), sd(x)*2), col = 4, lwd = 2,yaxt='n',xaxt='n',ylab="")
给予,