0

我有一个正在为每小时数据集编写的代码,并且想要显示一个正确的小波图,但我无法根据自己的喜好调整它。我想改变 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 轴

这将显示颜色条,但没有标记正确的 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)

无 x 轴,但存在彩条

4

1 回答 1

0

通过键入进入函数本身plot.biwavelet,将其复制到脚本编辑器并编辑函数,给它一个新名称,例如myplot,编辑它然后运行myplot而不是plot.biwavelet。您可以在plot.biwavelet函数中更改任何您想要的内容。例如,要增加 xlim 标签的数量,只需执行以下操作:locs <- pretty(range(xlim), n = 10). 目前,n=5.

于 2017-05-12T17:12:15.833 回答