双波包:"axis"包不管用 [英] biwavelet package: "axis" is not working
问题描述
我正在使用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 axis
is 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屋!