如何在时间序列图的 x 轴上更正每月日期格式?

问题描述 投票:0回答:0

我有一个包含两列的 .csv 文件

date,data
200601,433
200602,267
200603,322
..
..
..
200705,234

(日期格式为yyyymm;为月均数据) 我正在尝试使用以下代码将此数据绘制为线时间序列。

library(ggplot2)
library(zoo)

to.ym <- function(x) as.yearmon(as.character(x), "%Y%m")
alb_mean <- read.csv.zoo("alb_mean.csv", FUN = to.ym)
plot(alb_mean)

我能够获得该图,但 x 轴上的日期显示不同,如 200610、200620...200750。我不明白为什么会这样。为了简单起见,有没有办法让日期在图中显示为 2006 年 1 月、2006 年 2 月?

r ggplot2 time-series raster zoo
© www.soinside.com 2019 - 2024. All rights reserved.