Creating a Multi-Project Timeline Using ggplot2 in R

泄露秘密 提交于 2019-12-06 09:19:56

I chose to use segment and not ribbon because it's straight lines and segments are much easier to work with with a discrete y-axis.

#make ordered factor so that sequence in legend matches sequence in plot
data$Phase_ordered <- factor(data$Phase,levels=c("SD","DD","CD","PC","CA"))

p1 <- ggplot(data,aes(x=StartDate, y=Project, color=Phase_ordered)) +
  geom_segment(aes(x=StartDate,xend=EndDate,yend=Project),size=15) +
 scale_colour_discrete(guide=guide_legend(override.aes=list(size=7))) #or legend will be too big
p1

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!