Is there a way force R to print time stamps as %m/%d/%Y on graphs? When I have short (<7 days) of data it prints as days of the week as below?
plot(station_171$datetime, station_171$stageheight, pch=ifelse(station_171$outcode ==122,24,21), col="black", bg=ifelse(station_171$outcode ==122,"red","NA")
, xlab = "",xlim = c(min(station_101_7$datetime),max(station_101_7$datetime)), ylab = "")
legend("topright","171", bty = "n", cex=2)
You can format the axis using axis.POSIXct
as seen below:
axis.POSIXct(1,station_171$datetime, format = '%Y-%m-%d %H:%S')
One should also make sure to include the xaxt='n'
in the plot function to avoid double printing the x-axis labels.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.