|
@@ -5,36 +5,35 @@ parser <- ArgumentParser(description="Create plots for aggregated cluster data")
|
5
|
5
|
parser$add_argument("cluster_file", help = "file to visualise")
|
6
|
6
|
parser$add_argument("-i", "--img-path", dest = "img_path", default = "../img/", help = "path to store plots in; default: ../img/")
|
7
|
7
|
parser$add_argument("-p", "--postfix", dest = "postfix", default = "_plot", help = "postfix for files, default: _plot")
|
8
|
|
-parser$add_argument("-v", "--virtualenv", dest = "virtualenv", default = "../venv/", help = "path of virtualenv; default: ../venv/; '-' for none")
|
9
|
8
|
parser$add_argument("--width", dest = "width", default = 40, help = "width (cm), default 40", type = "double")
|
10
|
9
|
parser$add_argument("--height", dest = "height", default = 25, help = "height (cm), default 25", type = "double")
|
|
10
|
+parser$add_argument("--pkl", dest = "csv", help = "load from pickle instead of csv", action = "store_false")
|
11
|
11
|
|
12
|
12
|
args <- parser$parse_args()
|
13
|
13
|
|
14
|
|
-library(reticulate)
|
15
|
|
-library(ggplot2)
|
16
|
|
-library(dplyr)
|
17
|
|
-library(tidyr)
|
18
|
|
-library(TSA)
|
19
|
|
-library(forecast)
|
|
14
|
+print(args)
|
|
15
|
+
|
|
16
|
+library(ggplot2, warn.conflicts = FALSE, quietly = TRUE)
|
|
17
|
+library(dplyr, warn.conflicts = FALSE, quietly = TRUE)
|
|
18
|
+library(tidyr, warn.conflicts = FALSE, quietly = TRUE)
|
|
19
|
+library(TSA, warn.conflicts = FALSE, quietly = TRUE)
|
|
20
|
+library(forecast, warn.conflicts = FALSE, quietly = TRUE)
|
20
|
21
|
theme_set(theme_bw())
|
21
|
22
|
|
22
|
|
-if (args$virtualenv != "-") {
|
23
|
|
- print(args$virtualenv)
|
24
|
|
- use_virtualenv(args$virtualenv)
|
|
23
|
+if (args$csv) {
|
|
24
|
+ aggdf <- read.csv(args$cluster_file, header = TRUE, stringsAsFactors = FALSE)
|
|
25
|
+ aggdf$read_time <- as.POSIXct(aggdf$read_time)
|
|
26
|
+} else {
|
|
27
|
+ library(reticulate, warn.conflicts = FALSE, quietly = TRUE)
|
|
28
|
+ p <- import("pandas")
|
|
29
|
+ aggdf <- p$read_pickle(args$cluster_file)
|
25
|
30
|
}
|
26
|
|
-
|
27
|
|
-p <- import("pandas")
|
28
|
|
-aggdf <- p$read_pickle(args$cluster_file)
|
29
|
31
|
aggdf$cluster <- factor(aggdf$cluster)
|
30
|
|
-str(aggdf)
|
31
|
32
|
clusters = levels(aggdf$cluster)
|
32
|
33
|
cbp <- c('#0173b2', '#de8f05', '#029e73', '#d55e00', '#cc78bc', '#ca9161', '#fbafe4', '#949494', '#ece133', '#56b4e9', '#0173b2',
|
33
|
34
|
'#de8f05', '#029e73', '#d55e00', '#cc78bc', '#ca9161', '#fbafe4', '#949494', '#ece133', '#56b4e9', '#0173b2', '#de8f05',
|
34
|
35
|
'#029e73', '#d55e00', '#cc78bc', '#ca9161', '#fbafe4', '#949494', '#ece133', '#56b4e9', '#0173b2', '#de8f05', '#029e73',
|
35
|
|
- '#d55e00', '#cc78bc', '#ca9161', '#fbafe4', '#949494', '#ece133', '#56b4e9')[1:length(clusters)
|
36
|
|
-
|
37
|
|
-ggplot(aggdf, aes(y = kwh_tot_mean, x = cluster)) + geom_boxplot()
|
|
36
|
+ '#d55e00', '#cc78bc', '#ca9161', '#fbafe4', '#949494', '#ece133', '#56b4e9')[1:length(clusters)]
|
38
|
37
|
|
39
|
38
|
facall <- ggplot(aggdf, aes(x = read_time, y = kwh_tot_mean, color = cluster, fill = cluster)) +
|
40
|
39
|
geom_line(size = 1.5) + geom_ribbon(aes(ymin = kwh_tot_CI_low, ymax = kwh_tot_CI_high), alpha = 0.2, color = NA) +
|