我有一个正在为每小时数据集编写的代码,并且想要显示一个正确的小波图,但我无法根据自己的喜好调整它。我想改变 x-, y- 轴并放置一个彩条。但是,我已经成功更改了 x 轴,这只是在未激活彩条的情况下。如果是,那么我无法更改 x 轴。此外,我还没有找到一种成功的方法来更改 y 轴以使其之间的值比自动生成的值更多。预先感谢您的帮助
library(biwavelet) # used for wavelets
n <- 141696
d <- data.frame(1:n, round(runif(n, 38, 100),2))
# X-Axis for plotting
TIME1 <- as.POSIXlt("2000-01-01 00:00:00 PST", format = '%Y-%m-%d %H:%M:%S')
TIME2 <- as.POSIXlt("2016-02-29 23:00:00 PST", format = '%Y-%m-%d %H:%M:%S')
LABELS <- seq(from = TIME1, to = TIME2, by = "3 months")
xAxis <- seq(from = TIME1, to = TIME2, by = "hour")
Location <-NA
for (i in 1:length(LABELS)) { Location[i] <- which(LABELS[i] == xAxis) }
LABELS <- format(LABELS, "%b %Y")
# Wavelet
WAV <- wt(d)
这具有正确的 x 轴,但不显示颜色条,因为我没有将plot.cb = TRUE
绘图作为参数。
# PLOT (Has no legend but correct x-axis)
par(oma=c(0, 0, 0, 1), mar=c(5, 4, 4, 5) + 0.1)
plot(WAV, type="power.corr.norm", main="Bias-corrected wavelet power ", ylab="Period(hourly)", xlab="Time", lwd.sig=1, xaxt='n')
axis(side = 1, at = Location, labels = LABELS, tick = TRUE, las = 2)
这将显示颜色条,但没有标记正确的 x 轴。
# PLOT (Has legend but no x-axis)
par(oma=c(0, 0, 0, 1), mar=c(5, 4, 4, 5) + 0.1)
plot(WAV, type="power.corr.norm", main="Bias-corrected wavelet power ", ylab="Period(hourly)", xlab="Time", lwd.sig=1, xaxt='n', plot.cb=TRUE)
axis(side = 1, at = Location, labels = LABELS, tick = TRUE, las = 2)