如何在R中的填充等高线图中获得轮廓线和轴标签

时间:2014-08-14 08:04:23

标签: r contour axis-labels

我发现我可以获得具有错误轴标签的轮廓线,或者正确的轴标签和没有轮廓线。以下是产生前者的一些代码:

x<-c(1:10)
y<-c(1:10)
z<-matrix(x,nrow=length(x),ncol=length(y))
filled.contour(z,plot.axes = { contour(z, nlevels = 20, 
                                     drawlabels = T, axes = FALSE, 
                                     frame.plot = FFALSE, add = TRUE);
                 axis(1); axis(2) } )

这里有一些产生后者:

x<-c(1:10)
y<-c(1:10)
z<-matrix(x,nrow=length(x),ncol=length(y))
filled.contour(x,y,z,plot.axes = { contour(z, nlevels = 20, 
                                     drawlabels = T, axes = FALSE, 
                                     frame.plot = FFALSE, add = TRUE);
                 axis(1); axis(2) } )

不同之处在于我指定了x和y值。有人知道如何获得两者吗?

提前举手

1 个答案:

答案 0 :(得分:3)

您在x电话中忘记了ycontour

x<-c(1:10)
y<-c(1:10)
z<-matrix(x,nrow=length(x),ncol=length(y))
filled.contour(x,y,z,plot.axes = { contour(x,y,z, nlevels = 20, 
                                 drawlabels = TRUE, axes = FALSE, 
                                 frame.plot = FALSE, add = TRUE);
             axis(1); axis(2) } )

enter image description here