From c4ccdd571ccef28dd30ff1e04690482710dbeac2 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 10 Sep 2018 23:17:30 +0200 Subject: [PATCH] docs: simplify and document that file --- docs/source/tuto_s4u/draw_gantt.R | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/docs/source/tuto_s4u/draw_gantt.R b/docs/source/tuto_s4u/draw_gantt.R index 68b18ff1e9..5fd230b83e 100644 --- a/docs/source/tuto_s4u/draw_gantt.R +++ b/docs/source/tuto_s4u/draw_gantt.R @@ -1,23 +1,18 @@ #!/usr/bin/env Rscript args = commandArgs(trailingOnly=TRUE) library(ggplot2) + +# Load and relabel the data df = read.csv(args[1], header=F, strip.white=T) names(df) = c("Type", "Actor", "Container", "Start", "End", "Duration", "Level", "State"); -ggplot(df) - geom_segment(aes(x=Start, xend=End, - y=Actor, yend=Actor,color=State), size=5) - scale_fill_brewer(palette="Set1") - theme_bw() - theme ( - plot.margin = unit(c(0,0,0,0), "cm"), - legend.spacing = unit(1, "mm"), - panel.grid = element_blank(), - legend.position = "top", - legend.justification = "left", - legend.box.spacing = unit(0, "pt"), - legend.box.margin = margin(0,0,0,0)) -> p; +# Actually draw the graph +p = ggplot(df) + geom_segment(aes(x=Start, xend=End, y=Actor, yend=Actor,color=State), size=5); + +# Cosmetics to compact the resulting graph p.height <- length(unique(df$Actor)) * 0.05 + 2; pdf(height = p.height) + +# Produce the pdf file plot(p) dev.off() -- 2.20.1