I have been looking at the documentation but I cannot figure out how to control the time stamp on the x-axis of a filled.contour()
plot in R. I have tried axis.POSIXct()
and plot.axes = {}
. But neither works for me.
Here is my simplified example:
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-axis labels are in year format. I would like the format to be %b-%y
for every month (e.g. May-16, June-16 etc). How do I do this?
Here's how to do it using the
plot.axes
option withaxis.Date
.