【发布时间】:2021-08-28 02:31:54
【问题描述】:
我有 19 天(9 月 11 日至 30 日)每 30 分钟采集一次的温度数据,我想更改我的 x 轴标签以显示每天或每隔一天,并将其标记为“第 1 天”、“第 1 天” 3", (...),而不是仅按日期标记的三天(“Sep 14”),如下一个链接所示:温度图。
时间数据属于 POSIXCT 类。我附上了我使用的 ggplot 编码。我要离开 #scale_x_datetime 来展示我失败的解决方案之一。
hoboplot <- ggplot(hobo, aes(x=time, y=Temperatura, color=Tratamiento))+
geom_path(size=0.86)+
scale_color_manual(values=c("#2166AC", "#92C5DE", "#FDDBC7", "#D6604D", "#B2182B"))+
# scale_x_datetime(labels=c("1", "3", "5", "7", "9", "11", "13", "15", "17", "19"),
# breaks = c(1, 3, 5, 7, 9, 11, 13, 15, 17, 19))+
theme_classic(base_size=18)+
labs(x="Días", y="Temperatura (°C)")+
geom_hline(yintercept=10, linetype="dashed", color = "#2166AC")+
geom_hline(yintercept=14, linetype="dashed", color = "#92C5DE")+
geom_hline(yintercept=18, linetype="dashed", color = "#FDDBC7")+
geom_hline(yintercept=22, linetype="dashed", color = "#D6604D")+
geom_hline(yintercept=26, linetype="dashed", color = "#B2182B")+
theme(legend.position = "right")+
guides(color=guide_legend(reverse=TRUE))
如果有任何帮助,我将不胜感激!
【问题讨论】:
标签: r ggplot2 axis-labels posixct