我不知道您所追求的情节有现成的功能,但在 R 中编写自己的脚本并不复杂。这是一个例子。
# Simulate the data (from normal distribution)
d<-rnorm(1000)
# Calculate the density of the data
xd<-density(d)$x
yd<-density(d)$y
# Specify how many curves to plot
no.of.curves<-51
# Open a new plot window
x11(6, 8)
# Set background to black
par(bg=1)
# The the initial plot
plot(x=xd, y=yd+(no.of.curves-1)/10, ylim=c(0,no.of.curves/10+max(yd)), col="grey50", type="l", lwd=2)
# Color the curve with black
polygon(xd, yd+(no.of.curves-1)/10-0.02, col="black", border=NA)
# Add more urves to the plot
for(i in 1:no.of.curves) {
lines(x=xd, y=yd+(no.of.curves-i)/10, ylim=c(0,no.of.curves/10+max(yd)), col="grey50", type="l", lwd=2)
polygon(xd, yd+(no.of.curves-i)/10-0.02, col="black", border=NA)
}
这应该创建一些概念上相似的东西,但不完全相同的情节:
如果这是您要查找的内容,则可以将上面的脚本转换为可以为任何数据集生成绘图的函数。您能否提供一些您想绘制的示例数据集?
对于注释中的数据,以下代码将产生填充区域而不是线条,并且颜色已经反转:
d<-structure(list(x = c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,
3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L),
y = c(1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L,
4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L), z = c(5.47,
3.36, 2.99, 3.04, 3.73, 3.25, 3.04, 2.19, 1.6, 2.63, 3.49,
2.48, 2.7, 1.6, 2.7, 3.33, 1.94, 2.39, 2.89, 2.94, 4.35,
3.21, 3.4, 3.36, 4.74)), .Names = c("x", "y", "z"), class = "data.frame", row.names = c(NA,
-25L))
yvals<-rev(unique(d$y))
plot(x=0, y=0, ylim=c(min(d$y), max(d$y)+max(d$z)), xlim=c(min(d$x), max(d$x)), type="n", axes=F, xlab="", ylab="")
for(i in 1:length(yvals)) {
a<-d[d$y==yvals[i],]
polygon(x=a$x, y=a$z+i, border="grey75", col="black")
}
对于这些数据,没有恒定的基线,并且多边形(彩色区域)看起来有点奇怪。