【问题标题】:ggplot2 : plotting the time at which events happenggplot2:绘制事件发生的时间
【发布时间】:2018-04-18 17:09:06
【问题描述】:

我有一个数据框df,看起来像这样:

Date        Heure    Event
2017-06-16  08:15    A
2017-06-16  08:20    B
2017-06-16  08:21    B
2017-06-16  10:12    A
2017-06-17  07:10    B
2017-06-17  07:15    A
2017-06-17  08:00    A
2017-06-17  08:45    A

如何使用ggplot2 根据一天中的时间或日期绘制事件总数?

如果我点一个简单的plot(df$Heure),我会得到一个工作结果,但我想使用ggplot2,因为它更可定制。我环顾四周,但像 this one 或 that one 这样的解释需要在 y 轴上绘制。

【问题讨论】:

    标签: r ggplot2


    【解决方案1】:

    您是否正在寻找类似以下的内容?

    ggplot(my_data, aes(Date)) +
      geom_bar()
    

    ggplot(my_data, aes(Heure)) +
      geom_bar()
    

    ggplot(my_data, aes(Date, fill = Event)) +
      geom_bar(position = position_dodge())
    

    【讨论】:

    • 是的!非常感谢:)
    猜你喜欢
    • 1970-01-01
    • 2011-11-21
    • 1970-01-01
    • 2017-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-20
    • 2018-07-05
    相关资源
    最近更新 更多