简体   繁体   English

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

[英]How to get contour lines AND axis labels in a filled contour plot in R

I have found that I can get either contour lines with incorrect axis labels, or correct axis labels and no contour lines. 我发现我可以得到带有不正确的轴标签的轮廓线,或者得到正确的轴标签而没有轮廓线的轮廓线。 Here is some code that produces the former: 这是产生前者的一些代码:

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

And here is some that produces the latter: 这是产生后者的一些东西:

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

The difference is that I specified the x and y values. 区别在于我指定了x和y值。 Does anybody know how to get both? 有人知道如何同时获得两者吗?

Thnaks in advance 提前致谢

You forgot x and y in the contour call: 您在contour调用中忘记了xy

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

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM