R 中的阴影区域仅具有 Y 轴上的点
Shaded area in R only with point in axis Y
例如,我只有 Y 的数据:
55.64
79.21
47.8
28.52
43.99
83.02
87.04
85.44
但是我想用这些数据绘制一个阴影区域,这可能吗?
我不确定你想要实现什么,但这里有一种方法可以为 Y
定义的线下区域着色(假设相应的 x 值是 1 到 length(Y)
) ,使用纯色或阴影线:
par(mfrow=c(1, 2))
# plain color (grey)
plot(seq(Y), Y, type="l", main="plain color")
polygon(c(1, seq(Y), length(Y)), c(0, Y, 0), col="grey")
# shading lines
plot(seq(Y), Y, type="l", main="shading lines")
polygon(c(1, seq(Y), length(Y)), c(0, Y, 0), density=10)
例如,我只有 Y 的数据:
55.64
79.21
47.8
28.52
43.99
83.02
87.04
85.44
但是我想用这些数据绘制一个阴影区域,这可能吗?
我不确定你想要实现什么,但这里有一种方法可以为 Y
定义的线下区域着色(假设相应的 x 值是 1 到 length(Y)
) ,使用纯色或阴影线:
par(mfrow=c(1, 2))
# plain color (grey)
plot(seq(Y), Y, type="l", main="plain color")
polygon(c(1, seq(Y), length(Y)), c(0, Y, 0), col="grey")
# shading lines
plot(seq(Y), Y, type="l", main="shading lines")
polygon(c(1, seq(Y), length(Y)), c(0, Y, 0), density=10)