【问题标题】:Plot circular histogram with offset in ggplot2在ggplot2中绘制带有偏移的圆形直方图
【发布时间】:2017-03-19 12:39:42
【问题描述】:

我有我认为最适合绘制为极坐标直方图(玫瑰图)的时间数据。我想得到这样的结果:

而不是我得到的:

我特别想分散小值以使它们更容易看到,但在极坐标系上,宽度变为零,难以阅读。有没有办法使用 ggplot 做到这一点?

以下是数据:

   Arrival_h<-c(3,3,4,5,5,6,6,7,7,7,7,8,9,9,9,9,9,9,9,9,10,10,10,10,11,11,11,11,11,12,12,12,12,12,13,13,13,13,14,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,19,19)
  HKArr<-data.frame(Arrival_h)

【问题讨论】:

    标签: r plot ggplot2 histogram polar-coordinates


    【解决方案1】:

    一时兴起,我决定尝试修改 y 轴并解决了问题:

    这是一个比我之前没有偏移时更好的布局

    p<-ggplot(data=HKArr,aes(x=Arrival_h))+
      geom_histogram(fill='blue',color='black',breaks=c(1:24))+coord_polar()+
      scale_x_continuous("", limits = c(0, 24), 
                         breaks = seq(0, 24), labels = seq(0,24))
    p
    

    产生这个:

    ...添加 y 偏移量:

    p<-ggplot(data=HKArr,aes(x=Arrival_h))+
      geom_histogram(fill='blue',color='black',breaks=c(1:24))+coord_polar()+
      scale_x_continuous("", limits = c(0, 24), 
                         breaks = seq(0, 24), labels = seq(0,24))+
      scale_y_continuous("",limits=c(-2,10))
    p
    

    给出这个,我认为它更容易阅读:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-06-01
      • 1970-01-01
      • 2022-01-21
      • 2020-03-10
      • 2014-03-07
      • 1970-01-01
      • 2012-09-13
      相关资源
      最近更新 更多