我有一个代码,我正在处理每小时数据集,并希望显示一个正确的小波图,但我无法根据自己的喜好调整它。我想改变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)
答案 0 :(得分:0)
通过输入plot.biwavelet
进入函数本身,将其复制到脚本编辑器并编辑该函数,为其指定一个新名称,例如myplot
,然后编辑它,然后再运行myplot
plot.biwavelet
。您可以在plot.biwavelet
函数中更改所需内容。例如,要增加xlim标签的数量,只需执行:locs <- pretty(range(xlim), n = 10)
。目前,n=5
。