【问题标题】:Plot with R - labels on x axis在 x 轴上绘制 R - 标签
【发布时间】:2021-08-12 08:23:47
【问题描述】:

我使用下面的代码来获取每日天气:

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 )")

得到这样的图表:

我的问题,如何在 x 轴上获得带有每日数据的年份标签?

【问题讨论】:

  • 你已经有日期了(有太多的日期,它们会叠印并给你黑线)。看看(比如说)stackoverflow.com/a/30020683,看看如何改变休息时间

标签: r dataframe plot


【解决方案1】:

添加类似:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-05
    • 1970-01-01
    • 2016-04-10
    • 1970-01-01
    • 1970-01-01
    • 2016-08-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多