我是R的新手并尝试在同一个绘图中绘制多个2D等高线图。我尝试使用以下代码。
dat1 <- structure(list(x1 = c(1:10), y1 = c(10:20)), .Names = c("x1", "y1"), class = "data.frame", row.names = c(NA,-21L))
dat2 <- structure(list(x2 = c(10:20), y2 = c(20:30)), .Names = c("x2", "y2"), class = "data.frame", row.names = c(NA,-21L))
Contourcolors <- colorRampPalette(c('yellow',"red"))(20)
PointColors <- c(rep('green',5),rep('blue',5))
filled.contour(z=dat1,col=Contourcolors,
plot.axes=points( x=seq(0, 1, length.out = nrow(dat1)),
y=rep(.5,20),
col=PointColors,cex=5,pch=19)
)
Error in as.matrix.data.frame(x) :
length of 'dimnames' [2] not equal to array extent
如何使用R轻松完成此操作?