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