Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add gatherv test
[simgrid.git] / docs / source / tuto_s4u / draw_gantt.R
index 5fd230b83efb3476daf35244b4e223a403c71669..e412cd494af6dbb41708cfa9f686aeec6485755e 100644 (file)
@@ -1,16 +1,20 @@
 #!/usr/bin/env Rscript
 args = commandArgs(trailingOnly=TRUE)
-library(ggplot2)
+library(tidyverse)
+library(pajengr)
 
 # 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");
-
-# Actually draw the graph
-p = ggplot(df) + geom_segment(aes(x=Start, xend=End, y=Actor, yend=Actor,color=State), size=5);
+df = pajeng_read(args[1])
+df$state %>%
+    # rename some columns to use SimGrid terminology
+    rename(Actor = Container,
+           State = Value) %>%
+    # do the plot
+    ggplot() +
+    geom_segment(aes(x=Start, xend=End, y=Actor, yend=Actor, color=State), size=5) -> p
 
 # Cosmetics to compact the resulting graph
-p.height <- length(unique(df$Actor)) * 0.05 + 2;
+p.height <- length(unique(df$state$Actor)) * 0.05 + 2
 pdf(height = p.height)
 
 # Produce the pdf file