2016-05-18 109 views
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) 

No Color Bar, correct x-axis

這將顯示顏色條,但不具有正確的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

回答

0

獲取到函數本身通過鍵入plot.biwavelet,將它複製到你的腳本編輯器和編輯功能,給它一個新的名字,如myplot,對其進行編輯,然後運行的myplot代替plot.biwavelet。你可以在plot.biwavelet函數內改變你想要的。例如,要增加xlim標籤的數量,只需:locs <- pretty(range(xlim), n = 10)。目前,n=5