我有一个代码,我正在为每小时的数据集工作,并希望显示适当的小波图,但我在调整它以适应我的喜好时遇到了麻烦。我想改变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)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
发布于 2017-05-13 01:12:16
通过键入plot.biwavelet进入函数本身,将其复制到脚本编辑器并编辑函数,为其指定一个新名称,如myplot,然后运行myplot而不是plot.biwavelet。您可以在plot.biwavelet函数中随意更改。例如,要增加xlim标签的数量,只需执行:locs <- pretty(range(xlim), n = 10)。目前,n=5。
https://stackoverflow.com/questions/37305790
复制相似问题