0
我有一个代码,我正在为小时数据集工作,并希望显示一个适当的小波图,但我无法根据自己的喜好进行调整。我想改变x轴,y轴并放置一个颜色条。但是,我已经成功更改了x轴,只有当颜色条未激活时才会这样。如果是,那么我不能改变x轴。另外,我还没有找到一种成功的方法来改变y轴,以便在它们之间自动生成更多的值。预先感谢您的帮助小波图:改变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)
No x-axis, but color bar present