1

我正在尝试filled.countour在 R 中为函数添加点。但我没有取得任何成功。我跟着这个旧帖子。我的情节只是显示了一个绿色的点。我正在寻找一系列点,这些点会根据色带(PointColors在这种情况下)指定改变颜色。想不通为什么...

这是我的代码:

dat1 <-structure(c(5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 8.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 6.9, 5.5, 8.5, 5.5, 6.9, 6.9, 5.5, 5.5, 5.6, 6.9, 5.5, 5.5, 5.5, 8.1, 5.5, 5.5, 5.5, 5.5, 5.5, 7.5, 5.5, 5.5, 5.5, 7.5, 5.7, 4.6, 5.7, 5.5, 5.5, 5.7, 6.5, 3.2, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 8.2, 5.5, 8.2, 5.5, 5.5, 5.6, 5.5, 5.5, 5.1, 5.5, 5.5, 5.5, 5.5, 6.3, 5.5, 3.6, 5.5, 5.5, 5.5, 5.5, 5.5, 6.2, 5.4, 6.6, 5.5, 5.8, 6.2, 5.5, 5.5, 5.5, 5.6, 5.4, 5.5, 5.8, 5.5, 5.5, 5.5, 6.1, 5.5, 6.5, 2.3, 5.5, 6.1, 5.5, 5.5, 7, 5.5, 5.8, 5.5, 5.5, 7.6, 4.1, 5.5, 6.8, 4.6, 1.5, 5.5, 5.5, 5.7, 5.7, 5.5, 3.4, 5.7, 5.5, 5.5, 5.5, 5.5, 5.7, 7.4, 5.7, 5.5, 5.7, 5.5, 5.5, 5, 1, 5.5, 4.2, 2.2, 5.5, 4.7, 3.2, 5.5, 4.5, 4.5, 4, 2.4, 5.5, 2.5, 4.1, 5.7, 5.5, 1.9, 3.6, 4.6, 3, 4.6, 5.5, 4, 3.7, 5.5, 4.6, 5.5, 5.5, 4.6, 4.7, 3.6, 5.5, 5.5, 4.6, 3.7, 4.6, 4.6, 6, 4, 5.5, 4.9, 1.6, 5.5, 6.6, 5.2, 6.4, 6.4, 4.9, 6.2, 6.2, 6.5, 6.4, 5.3, 5.5, 3.6, 5.7, 7.4, 5.9, 2.4, 5.3, 8.5, 5.3, 5.5, 7.4, 6, 5.5, 5.5, 3.3, 4.6, 8.5, 6.1, 5.5, 5.5, 5.5, 5.5, 6.9, 5.5, 6.5, 7, 6.4, 5.3, 8.2, 7.3, 2.4, 7.1, 6.3, 7.7, 3.9, 8.2, 6.3, 6.7, 8, 7.2, 5.6, 4.7, 7.7, 6.6, 5.2, 5.5, 5.2, 5.3, 5.2, 5.4, 5.5, 2.8, 7, 5.7, 6.8, 4.6, 6.2, 5.5, 5.8, 7.3, 5.1, 4.8, 3.5, 5.5, 5.8, 6.4, 6.7, 5.5, 5.5, 5.5, 5.5, 4.8, 6.7, 4.7, 7.2, 5.5, 3.5, 5.5, 4.9, 5.5, 5.5, 6.7, 3.7, 5.5, 5.5), .Dim = c(20L, 16L), .Dimnames = list(NULL, c("estimated", "estimated", "estimated", "estimated", "estimated", "estimated", "estimated", "estimated", "estimated", "estimated", "estimated", "estimated", "estimated", "estimated", "estimated", "estimated")))

Contourcolors <- colorRampPalette(c('yellow',"red"))(20)
PointColors <- c(rep('green',5),rep('blue',5))
filled.contour(dat1,col=Contourcolors,plot.axes={points((1:20),rep(.5,20),col=PointColors,cex=5,pch=19)})

这是情节。 在此处输入图像描述

4

1 回答 1

4

我想你会发现如果你看一下代码,填充的 xy 尺寸已缩放到 [0,1] 并且你需要将你的点调用缩放到相同的变换。

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)
               )

有点奇怪的情节,但似乎是你所要求的。

在此处输入图像描述

于 2013-06-10T02:25:19.363 回答