Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cosmetics: fix "Malformed whitespace in C++" spotted by codefactor.io.
[simgrid.git] / docs / source / tuto_s4u / draw_gantt.R
index 68b18ff..3e9afb7 100644 (file)
@@ -1,23 +1,19 @@
 #!/usr/bin/env Rscript
 args = commandArgs(trailingOnly=TRUE)
 library(ggplot2)
-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;
+library(pajengr)
 
-p.height <- length(unique(df$Actor)) * 0.05 + 2;
+# Load and relabel the data
+df = pajeng_read(args[1])
+names(df$state) = c("Type", "Actor", "Container", "Start", "End", "Duration", "Level", "State")
+
+# Actually draw the graph
+p = ggplot(df$state) + 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$state$Actor)) * 0.05 + 2
 pdf(height = p.height)
+
+# Produce the pdf file
 plot(p)
 dev.off()