Skip to content

Instantly share code, notes, and snippets.

@tleonardi
Last active August 29, 2015 14:13
Show Gist options
  • Save tleonardi/7a552a0154e91e32cba0 to your computer and use it in GitHub Desktop.
Save tleonardi/7a552a0154e91e32cba0 to your computer and use it in GitHub Desktop.
Gantt charts with ggplot2
library(reshape2)
library(ggplot2)
tasks <- c("M1.1: Text \n here",
"M1.2: Text \n here",
"M1.3: Text \n here",
"M2.1: Text \n here",
"M2.2: Text \n here",
"M2.3: Text \n here"
)
dfr <- data.frame(
name = factor(rev(tasks), levels = rev(tasks)),
start.date = rev(c(1,10,16,1,10,19)),
end.date = rev(c(10,16,36,10,19,36)),
WP = as.factor(rev(c("WP1", "WP1", "WP1", "WP2", "WP2", "WP2")))
)
mdfr <- melt(dfr, measure.vars = c("start.date", "end.date"))
ggplot(mdfr, aes(value, name, colour = WP)) +
geom_line(size = 6) +
ylab(NULL) +
xlab("Months") + scale_x_discrete() + theme_bw()
@meteoral2
Copy link

nyny

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment