[英]Plotting discrete count data as “staple” of points in ggplot2
我的目标是绘制一些乐队在音乐节上的演出频率。 基本上,该图应如下所示:
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))
您可以执行此操作,但是需要一些手动调整刻度才能看起来不错。
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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.