简体   繁体   English

Plot 与 R - x 轴上的标签

[英]Plot with R - labels on x axis

I'm using the code below for the daily weather:我将以下代码用于每日天气:

library(ggplot2)
options(repr.plot.width=16, repr.plot.height=9)

ggplot(df,aes(x = Date, y = MADRID)) +
  geom_line(group = 1, color='lightblue')+
  scale_y_continuous(limits = c(5,30), breaks = seq(5,30,5)) +
  ggtitle ("Daily average temperature - MADRID") +
  xlab("Date") +  ylab ("Average Temperature ( ºC )")

And getting such a graph:并得到这样的图表:

在此处输入图像描述

My question, how to get labels with years having daily data on the x axis?我的问题是,如何获得在 x 轴上具有每日数据的年份的标签?

Add something like:添加类似:

plot + scale_x_date(labels = date_format("%d/%m/%Y"), breaks = date_breaks("1 year"))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM