Browse Source

Cluster visualisation images

Petra Lamborn 5 years ago
parent
commit
1705c988c3
11 changed files with 75 additions and 9 deletions
  1. 75
    9
      R/clusterviz.R
  2. BIN
      img/all-9-fix.png
  3. BIN
      img/all-9-fre.png
  4. BIN
      img/apr-9-fix.png
  5. BIN
      img/apr-9-fre.png
  6. BIN
      img/jan-9-fix.png
  7. BIN
      img/jan-9-fre.png
  8. BIN
      img/jul-9-fix.png
  9. BIN
      img/jul-9-fre.png
  10. BIN
      img/oct-9-fix.png
  11. BIN
      img/oct-9-fre.png

+ 75
- 9
R/clusterviz.R View File

@@ -14,14 +14,80 @@ str(aggdf)
14 14
 
15 15
 ggplot(aggdf, aes(y = kwh_tot_mean, x = cluster)) + geom_boxplot()
16 16
 
17
-ggplot(aggdf, aes(x = read_time, y = kwh_tot_mean, color = cluster)) + 
18
-    geom_line() + facet_grid(cluster ~ .) +
19
-    labs(title = "Cluster behaviour over full year", x = "Date and time", y = "kwh") +
20
-    scale_color_manual(values = cbp)
17
+facall <- ggplot(aggdf, aes(x = read_time, y = kwh_tot_mean, color = cluster, fill = cluster)) + 
18
+    geom_line(size = 1.5) + geom_ribbon(aes(ymin = kwh_tot_CI_low, ymax = kwh_tot_CI_high), alpha = 0.2, color = NA) +
19
+    labs(title = "Cluster behaviour over full year, 2017", x = "Date", y = "kwh") +
20
+    scale_color_manual(values = cbp) +
21
+    scale_fill_manual(values = cbp) +
22
+    theme(legend.position = "none") +
23
+    scale_x_datetime(date_breaks = "1 month", date_labels = "%-d %B")
21 24
 
22
-midjan <- filter(aggdf, read_time > as.POSIXct("2017-01-15"), read_time <= as.POSIXct("2017-01-21"))
25
+allcon <- facall + facet_grid(cluster ~ .)
26
+allfre <- facall + facet_grid(cluster ~ ., scales = "free")
27
+
28
+midjan <- filter(aggdf, read_time >= as.POSIXct("2017-01-15", tz = "UTC"), read_time <= as.POSIXct("2017-01-22", tz = "UTC"))
29
+
30
+facjan <- ggplot(midjan, aes(x = read_time, y = kwh_tot_mean, color = cluster, fill = cluster)) + 
31
+    geom_line(size = 1.5) + geom_ribbon(aes(ymin = kwh_tot_CI_low, ymax = kwh_tot_CI_high), alpha = 0.2, color = NA) +
32
+    labs(title = "Cluster behaviour over third week of January", x = "Date", y = "kwh") +
33
+    scale_color_manual(values = cbp) +
34
+    scale_fill_manual(values = cbp) +
35
+    theme(legend.position = "none") +
36
+    scale_x_datetime(date_breaks = "1 day", date_labels = "%a, %-d %B %Y")
37
+
38
+jancon <- facjan + facet_grid(cluster ~ .)
39
+janfre <- facjan + facet_grid(cluster ~ ., scales = "free")
40
+
41
+
42
+midap <- filter(aggdf, read_time >= as.POSIXct("2017-04-16", tz = "UTC"), read_time <= as.POSIXct("2017-04-23", tz = "UTC"))
43
+
44
+facap <- ggplot(midap, aes(x = read_time, y = kwh_tot_mean, color = cluster, fill = cluster)) + 
45
+    geom_line(size = 1.5) + geom_ribbon(aes(ymin = kwh_tot_CI_low, ymax = kwh_tot_CI_high), alpha = 0.2, color = NA) +
46
+    labs(title = "Cluster behaviour over third week of April 2017", x = "Date", y = "kwh") +
47
+    scale_color_manual(values = cbp) +
48
+    scale_fill_manual(values = cbp) +
49
+    theme(legend.position = "none") +
50
+    scale_x_datetime(date_breaks = "1 day", date_labels = "%a, %-d %B %Y")
51
+
52
+apcon <- facap + facet_grid(cluster ~ .)
53
+apfre <- facap + facet_grid(cluster ~ ., scales = "free")
54
+
55
+
56
+midjul <- filter(aggdf, read_time >= as.POSIXct("2017-07-16", tz = "UTC"), read_time <= as.POSIXct("2017-07-23", tz = "UTC"))
57
+
58
+facjul <- ggplot(midjul, aes(x = read_time, y = kwh_tot_mean, color = cluster, fill = cluster)) + 
59
+    geom_line(size = 1.5) + geom_ribbon(aes(ymin = kwh_tot_CI_low, ymax = kwh_tot_CI_high), alpha = 0.2, color = NA) +
60
+    labs(title = "Cluster behaviour over third week of July 2017", x = "Date", y = "kwh") +
61
+    scale_color_manual(values = cbp) +
62
+    scale_fill_manual(values = cbp) +
63
+    theme(legend.position = "none") +
64
+    scale_x_datetime(date_breaks = "1 day", date_labels = "%a, %-d %B %Y")
65
+
66
+julcon <- facjul + facet_grid(cluster ~ .)
67
+julfre <- facjul + facet_grid(cluster ~ ., scales = "free")
68
+
69
+
70
+midoct <- filter(aggdf, read_time >= as.POSIXct("2017-10-15", tz = "UTC"), read_time <= as.POSIXct("2017-10-22", tz = "UTC"))
71
+
72
+facoct <- ggplot(midoct, aes(x = read_time, y = kwh_tot_mean, color = cluster, fill = cluster)) + 
73
+    geom_line(size = 1.5) + geom_ribbon(aes(ymin = kwh_tot_CI_low, ymax = kwh_tot_CI_high), alpha = 0.2, color = NA) +
74
+    labs(title = "Cluster behaviour over third week of October 2017", x = "Date", y = "kwh") +
75
+    scale_color_manual(values = cbp) +
76
+    scale_fill_manual(values = cbp) +
77
+    theme(legend.position = "none") +
78
+    scale_x_datetime(date_breaks = "1 day", date_labels = "%a, %-d %B %Y")
79
+
80
+octcon <- facoct + facet_grid(cluster ~ .)
81
+octfre <- facoct + facet_grid(cluster ~ ., scales = "free")
82
+
83
+ggsave("all-9-fix.png", allcon, path = "../img/", dpi = "retina", width = 40, height = 25, units = "cm")
84
+ggsave("all-9-fre.png", allfre, path = "../img/", dpi = "retina", width = 40, height = 25, units = "cm")
85
+ggsave("jan-9-fix.png", jancon, path = "../img/", dpi = "retina", width = 40, height = 25, units = "cm")
86
+ggsave("jan-9-fre.png", janfre, path = "../img/", dpi = "retina", width = 40, height = 25, units = "cm")
87
+ggsave("apr-9-fix.png",  apcon, path = "../img/", dpi = "retina", width = 40, height = 25, units = "cm")
88
+ggsave("apr-9-fre.png",  apfre, path = "../img/", dpi = "retina", width = 40, height = 25, units = "cm")
89
+ggsave("jul-9-fix.png", julcon, path = "../img/", dpi = "retina", width = 40, height = 25, units = "cm")
90
+ggsave("jul-9-fre.png", julfre, path = "../img/", dpi = "retina", width = 40, height = 25, units = "cm")
91
+ggsave("oct-9-fix.png", octcon, path = "../img/", dpi = "retina", width = 40, height = 25, units = "cm")
92
+ggsave("oct-9-fre.png", octfre, path = "../img/", dpi = "retina", width = 40, height = 25, units = "cm")
23 93
 
24
-ggplot(midjan, aes(x = read_time, y = kwh_tot_mean, color = cluster)) + 
25
-    geom_line() + facet_grid(cluster ~ .) +
26
-    labs(title = "Cluster behaviour over third week of January", x = "Date and time", y = "kwh") +
27
-    scale_color_manual(values = cbp)

BIN
img/all-9-fix.png View File


BIN
img/all-9-fre.png View File


BIN
img/apr-9-fix.png View File


BIN
img/apr-9-fre.png View File


BIN
img/jan-9-fix.png View File


BIN
img/jan-9-fre.png View File


BIN
img/jul-9-fix.png View File


BIN
img/jul-9-fre.png View File


BIN
img/oct-9-fix.png View File


BIN
img/oct-9-fre.png View File