【问题标题】:Plotting discrete count data as "staple" of points in ggplot2将离散计数数据绘制为 ggplot2 中点的“主食”
【发布时间】:2015-08-20 04:10:31
【问题描述】:

我的目标是绘制一些乐队在音乐节上演奏的频率。基本上,情节应该是这样的:

ggplot(plot.df2, aes(reorder(bands,count),count)) + geom_point() + coord_flip()+ theme_bw()

但我想为每次乐队在那里演奏过的每一场比赛加分。这将是一个像这样的“要点”:

ggplot(plot.df2, aes(count)) + geom_dotplot()+ coord_flip()+theme_bw()

这在 ggplot2 中可行吗?

这是一些示例数据:

bands<-c("Queens of the Stone Age","The Sounds","Beatsteaks","Billy Talent","Donots","The Hives","Tocotronic")
count<-c(6,6,5,5,5,5,5)
plot.df<-as.data.frame(cbind(bands,count))

【问题讨论】:

    标签: r plot ggplot2


    【解决方案1】:

    您可以这样做,但需要手动调整音阶才能看起来不错。

    plot.df <- data.frame(band = rep(bands, count),
                          count = unlist(lapply(count, seq_len)))
    ggplot(plot.df, aes(x = count, y=band)) +
        geom_point() + scale_x_continuous(limits=c(0, 10), breaks=seq(0, 10, by=2)
    

    【讨论】:

      猜你喜欢
      • 2018-05-23
      • 1970-01-01
      • 2021-05-10
      • 2017-12-08
      • 2020-04-30
      • 1970-01-01
      • 2023-01-11
      • 2015-10-01
      • 2018-02-13
      相关资源
      最近更新 更多