This is a simple script that creates a Gantt chart using ggplot. The variables should be quite self-explanatory, anyway here’s what you need to change:

  • tasks: vector of labels (usually milestone descriptions) for each task
  • start.date: start months for each tasks
  • start.date: end months for each tasks
  • WP: Work packages description for each task. This factor will be used to colour tasks.
library(reshape2)
library(ggplot2)
 
tasks <- c(
"M1.1: Text here", 
"M1.2: Text here", 
"M1.3: Text here",
"M2.1: Text here",
"M2.2: Text here",
"M2.3: Text 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()