[英]Controlling x-axis label format for time series plots - R
有沒有辦法強制 R 在圖表上將時間戳打印為 %m/%d/%Y? 當我的數據很短(<7 天)時,它會打印為一周中的幾天,如下所示?
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)
您可以使用axis.POSIXct
格式化軸,如下所示:
axis.POSIXct(1,station_171$datetime, format = '%Y-%m-%d %H:%S')
還應確保在繪圖函數中包含xaxt='n'
以避免重復打印 x 軸標簽。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.