问题
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))
回答1:
The thing that was breaking your plot was plot.cb = TRUE
.
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!
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!
来源:https://stackoverflow.com/questions/38278211/biwavelet-package-axis-is-not-working