updates
[phd-thesis.git] / tvt / img / gen_stacked_barchart.py
index af3d6ec..ec73abb 100644 (file)
@@ -44,7 +44,8 @@ print(df)
 
 fig, ax = plt.subplots()
 
-ax.bar(df.columns, df.loc[components[-1]], label=components[-1])
+ax.bar(df.columns, df.loc[components[-1]], label=components[-1],
+        color=CB_color_cycle[-1])
 baseline = df.loc[components[-1]]
 for i in range(len(components)-2, -1, -1):
     ax.bar(df.columns, df.loc[components[i]], label=components[i],
@@ -81,8 +82,7 @@ ax.set_position([box.x0, box.y0, box.width * 0.7, box.height])
 
 handles, labels = plt.gca().get_legend_handles_labels()
 ##order = list(range(len(components)))
-order = list(range(len(components)-1, -1, -1))
-plt.legend([handles[idx] for idx in order],[labels[idx] for idx in order], loc='center left', bbox_to_anchor=(1, 0.5))
+plt.legend(reversed(handles),reversed(labels), loc='center left', bbox_to_anchor=(1, 0.5))
 
 ##ax.legend()