我一直在查看文档,但我不知道如何控制filled.contour()
的x轴上的时间戳R中的情节。我尝试过axis.POSIXct()
和plot.axes = {}
。但两者都不适合我。
这是我的简化示例:
x1 <- seq(as.Date("2016-01-01"),as.Date("2018-07-01"),by="month")
z1 <- c(0.45062130 ,0.51136174 ,0.6 ,0.8 ,0.29481738 ,0.6 ,0.27713756 ,0.62638512 ,0.23547530,0.29253901 ,0.75899501 ,0.67779756 ,0.51831742 ,0.08050147 ,0.71183739 ,0.13154414 ,0.79406706 ,0.13154414,0.03434758 ,0.59573892 ,0.22102821 ,0.13154414 ,0.13154414 ,0.13154414 ,0.13154414 ,0.13154414 ,0.23692593,0.95215104 ,0.38810846 ,0.17970580 ,0.05176054)
z2 <- z1^2
z3 <- z2^2
df <- data.frame(x1,z1,z2,z3)
time <- c(x1)
depths <- c(1,2,3)
temp2 <- as.matrix(data.frame(df$z1,df$z2,df$z3))
temp2<- matrix(temp2,ncol=ncol(temp2), dimnames = NULL)
filled.contour(time,depths,temp2, col=(matlab.like2(28)),
ylab="Depth", xlab="Time",
key.title=title(expression(' Temp ('*degree*'C)')),xaxs="i")
X 轴标签采用年份格式。我希望格式为 %b-%y
每个月(例如 5 月至 16 日、6 月至 16 日等)。我该怎么做呢?
最佳答案
以下是如何使用 plot.axes
选项和 axis.Date
来完成此操作。
filled.contour(time,depths,temp2, #col=(matlab.like2(28)),
ylab="Depth", xlab="Time",
plot.axes = { axis.Date(side=1,x=time,at=time,format="%b-%y"); axis(2) },
key.title=title(expression(' Temp ('*degree*'C)')),xaxs="i")
关于r - 控制填充轮廓图上的 x 轴时间戳 - R,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41186998/