From 68ac0e959a982a89b594cc397752fad76cbe6e66 Mon Sep 17 00:00:00 2001 From: Aamir Siddiqui Date: Fri, 3 May 2024 11:42:46 +0100 Subject: [PATCH] set the bar colors based decreasing or increasing --- src/analyze/graph/analyze_quarterly_results.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/analyze/graph/analyze_quarterly_results.py b/src/analyze/graph/analyze_quarterly_results.py index f0f5f33..752ef14 100644 --- a/src/analyze/graph/analyze_quarterly_results.py +++ b/src/analyze/graph/analyze_quarterly_results.py @@ -55,6 +55,13 @@ def add_plots(self): self.plot_lap_times_stat(episodes, gs, np.median, 2, 1) + def diff_list(self, data): + new_list = [] + for i in range(len(data) - 1, 0, -1): + new_list.append(data[i] - data[i-1]) + new_list.append(data[0]) + return list(reversed(new_list)) + def plot_minimum_percents(self, episodes, gs, minimum_percent, graph_x, graph_y): axes :Axes = self.graph_figure.add_subplot(gs[graph_x, graph_y]) @@ -71,8 +78,10 @@ def plot_minimum_percents(self, episodes, gs, minimum_percent, graph_x, graph_y) plot_x = np.array([1, 2, 3, 4]) plot_y = get_data_minimum_percents(episodes, minimum_percent) + diffs = self.diff_list(plot_y) + colors = ["C1" if x > 0 else "C2" for x in diffs] - bars = axes.bar(plot_x, plot_y, color="C1") + bars = axes.bar(plot_x, plot_y, color=colors) for bar in bars: height = bar.get_height()