From f146de0e30cf3798b1d21418f8ad67c3d2a6784a Mon Sep 17 00:00:00 2001 From: "Julian M. Kunkel" Date: Thu, 3 Sep 2020 19:55:54 +0100 Subject: [PATCH] Plot impr --- scripts/plot.R | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/plot.R b/scripts/plot.R index 1a92c9e..1f985ce 100755 --- a/scripts/plot.R +++ b/scripts/plot.R @@ -1,5 +1,9 @@ #!/usr/bin/env Rscript +# Parse job from command line +args = commandArgs(trailingOnly = TRUE) +file = args[1] + library(ggplot2) library(dplyr) require(scales) @@ -12,10 +16,10 @@ plotjobs = TRUE # Color scheme plotcolors <- c("#CC0000", "#FFA500", "#FFFF00", "#008000", "#9999ff", "#000099") -# Parse job from command line -args = commandArgs(trailingOnly = TRUE) -file = "job_similarities_5024292.csv" # for manual execution -file = args[1] +if (! exists("file")){ + file = "job_similarities_5024292.csv" # for manual execution +} +print(file) jobID = str_extract(file, regex("[0-9]+")) data = read.csv(file) @@ -28,12 +32,12 @@ cat(nrow(data)) # empirical cumulative density function (ECDF) data$sim = data$similarity*100 -ggplot(data, aes(sim, color=alg_name, group=alg_name)) + stat_ecdf(geom = "step") + xlab("Similarity in %") + ylab("Fraction of jobs") + theme(legend.position=c(0.05, 0.5), legend.title = element_blank()) + scale_color_brewer(palette = "Set2") + scale_x_log10() +ggplot(data, aes(sim, color=alg_name, group=alg_name)) + stat_ecdf(geom = "step") + xlab("Similarity in %") + ylab("Fraction of jobs") + theme(legend.position=c(0.9, 0.5), legend.title = element_blank()) + scale_color_brewer(palette = "Set2") # + scale_x_log10() + ggsave("ecdf.png", width=8, height=2.5) # histogram for the jobs ggplot(data, aes(sim), group=alg_name) + geom_histogram(color="black", binwidth=2.5) + aes(fill = alg_name) + facet_grid(alg_name ~ ., switch = 'y') + xlab("Similarity in %") + scale_y_continuous(limits=c(0, 100), oob=squish) + scale_color_brewer(palette = "Set2") + ylab("Count (cropped at 100)") + theme(legend.position = "none") + stat_bin(binwidth=2.5, geom="text", adj=1.0, angle = 90, colour="black", size=3, aes(label=..count.., y=0*(..count..)+95)) -ggsave("hist-sim.png", width=6, height=4.5) +ggsave("hist-sim.png", width=6, height=5) #ggplot(data, aes(similarity, color=alg_name, group=alg_name)) + stat_ecdf(geom = "step") + xlab("SIM") + ylab("Fraction of jobs") + theme(legend.position=c(0.9, 0.4)) + scale_color_brewer(palette = "Set2") + xlim(0.5, 1.0) #ggsave("ecdf-0.5.png", width=8, height=3) @@ -56,7 +60,6 @@ plotJobs = function(algorithm, jobs){ script = "./scripts/plot-job-timelines-ks.py" }else{ script = "./scripts/plot-job-timelines.py" - return(0) ### FIXME } prefix = do.call("sprintf", list("%s-%.4f-", level, r$similarity)) call = sprintf("%s %s %s", script, paste(r$jobid, collapse=","), paste(prefix, collapse=","))