双波包:"axis"包不管用 [英] biwavelet package: "axis" is not working

查看:116
本文介绍了双波包:"axis"包不管用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用biwavelet包进行小波相干分析.当我想设置自己的x ticklabel时,我发现axis无法正常工作.下面给出了一个可重现的示例.谢谢.

I am using biwavelet package to conduct wavelet coherence analysis. When I want to set my own x ticklabel, I find axisis not working. The following gives a reproducible example. Thanks.

require(biwavelet)
t1 <- cbind(1:100, rnorm(100))
t2 <- cbind(1:100, rnorm(100))
wtc.t1t2 <- wtc(t1,t2,nrands = 10) 
plot(wtc.t1t2, plot.cb = TRUE, plot.phase = TRUE,xaxt='n')
axis(1,at = seq(10,100,10),labels = seq(1,10,1))

推荐答案

破坏情节的是plot.cb = TRUE.

plot.biwavelet的源代码中,作者注意到有关plot.cb选项的以下内容:

In the source code for plot.biwavelet the author notes the following about the plot.cb option:

##添加颜色条:这必须在所有操作之后进行,否则会造成混乱 随之而来!

## Add color bar: this must happen after everything, otherwise chaos ensues!

这就是问题所在–您在plot.cb之后调用了axis(),随后出现了混乱. 但是,您可以使用fields包中的image.plot手动添加回彩条,先运行plot而不使用plot.cb然后添加您的axis().

So that was the problem -- you invoked axis() after plot.cb and chaos ensued. However, you can manually add back the color bar using image.plot from the fields package, after having run plot without plot.cb then having added your axis().

pacman::p_load(biwavelet,fields)
t1 <- cbind(1:100, rnorm(100))
t2 <- cbind(1:100, rnorm(100))
wtc.t1t2 <- wtc(t1,t2,nrands = 10) 
plot(wtc.t1t2, plot.phase = TRUE,xaxt='n')
axis(1,at = seq(10,100,10),labels = seq(1,20,2))
image.plot( zlim=c(0,25), legend.only=TRUE)

您可以按照自己的喜好自定义刻度和颜色条!

You can customize the ticks and the color bar to your liking this way!

这篇关于双波包:"axis"包不管用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆