|
@@ -83,34 +83,39 @@ print(mdagg.describe())
|
83
|
83
|
|
84
|
84
|
# Algorithm via
|
85
|
85
|
# <https://stackoverflow.com/questions/38153829/custom-cluster-colors-of-scipy-dendrogram-in-python-link-color-func>
|
86
|
|
-ldict = {icp_id:cpal[cluster] for icp_id, cluster in zip(clustdf.icp_id, clustdf.cluster)}
|
87
|
|
-link_cols = {}
|
88
|
|
-for i, i12 in enumerate(lobj[:,:2].astype(int)):
|
89
|
|
- c1, c2 = (link_cols[x] if x > len(lobj) else ldict[clustdf.icp_id[x]]
|
90
|
|
- for x in i12)
|
91
|
|
- link_cols[i+1+len(lobj)] = c1 if c1 == c2 else '#000000'
|
92
|
|
-
|
93
|
|
-plt.figure(figsize = (25, 10))
|
94
|
|
-plt.title('ICP Clustering Dendrogram')
|
95
|
|
-plt.xlabel('ICP ID/(Number of ICPs)')
|
96
|
|
-plt.ylabel('distance')
|
97
|
|
-dendrogram(
|
98
|
|
- lobj,
|
99
|
|
- labels = cmat.index.values,
|
100
|
|
- leaf_rotation=90,
|
101
|
|
- leaf_font_size=8,
|
102
|
|
- # show_leaf_counts = True,
|
103
|
|
- # truncate_mode = 'lastp',
|
104
|
|
- # p = 50,
|
105
|
|
- # show_contracted = True,
|
106
|
|
- link_color_func = lambda x: link_cols[x],
|
107
|
|
- color_threshold = None
|
108
|
|
-)
|
109
|
|
-plt.show()
|
|
86
|
+# ldict = {icp_id:cpal[cluster] for icp_id, cluster in zip(clustdf.icp_id, clustdf.cluster)}
|
|
87
|
+# link_cols = {}
|
|
88
|
+# for i, i12 in enumerate(lobj[:,:2].astype(int)):
|
|
89
|
+# c1, c2 = (link_cols[x] if x > len(lobj) else ldict[clustdf.icp_id[x]]
|
|
90
|
+# for x in i12)
|
|
91
|
+# link_cols[i+1+len(lobj)] = c1 if c1 == c2 else '#000000'
|
|
92
|
+#
|
|
93
|
+# plt.figure(figsize = (25, 10))
|
|
94
|
+# plt.title('ICP Clustering Dendrogram')
|
|
95
|
+# plt.xlabel('ICP ID/(Number of ICPs)')
|
|
96
|
+# plt.ylabel('distance')
|
|
97
|
+# dendrogram(
|
|
98
|
+# lobj,
|
|
99
|
+# labels = cmat.index.values,
|
|
100
|
+# leaf_rotation=90,
|
|
101
|
+# leaf_font_size=8,
|
|
102
|
+# # show_leaf_counts = True,
|
|
103
|
+# # truncate_mode = 'lastp',
|
|
104
|
+# # p = 50,
|
|
105
|
+# # show_contracted = True,
|
|
106
|
+# link_color_func = lambda x: link_cols[x],
|
|
107
|
+# color_threshold = None
|
|
108
|
+# )
|
|
109
|
+# plt.show()
|
110
|
110
|
|
111
|
111
|
sns.set()
|
112
|
|
-ax = sns.lineplot(x = 'read_time', y = 'kwh_tot_mean', hue = 'cluster', data = mdagg, palette = cpal)
|
113
|
|
-for c in clabs:
|
|
112
|
+
|
|
113
|
+f, axes = plt.subplots(3,3)
|
|
114
|
+print(f)
|
|
115
|
+print(axes)
|
|
116
|
+
|
|
117
|
+for i, c in enumerate(clabs):
|
114
|
118
|
fds = mdagg[mdagg.cluster == c]
|
115
|
|
- ax.fill_between(fds.read_time.dt.to_pydatetime(), fds.kwh_tot_CI_low, fds.kwh_tot_CI_high, alpha = 0.1, color = cpal[c])
|
|
119
|
+ sns.lineplot(x = 'read_time', y = 'kwh_tot_mean', color = cpal[c], ax = axes[i//3][i%3], data = fds)
|
|
120
|
+ axes[i//3][i%3].fill_between(fds.read_time.dt.to_pydatetime(), fds.kwh_tot_CI_low, fds.kwh_tot_CI_high, alpha = 0.1, color = cpal[c])
|
116
|
121
|
plt.show()
|