From 1e5ed204377eb74849e4f2bec4f87967082c5d95 Mon Sep 17 00:00:00 2001 From: tomrink <rink@ssec.wisc.edu> Date: Thu, 24 Mar 2022 14:28:07 -0500 Subject: [PATCH] snapshot... --- modules/util/bar_plot.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/util/bar_plot.py b/modules/util/bar_plot.py index dd982bd7..b7017f8f 100644 --- a/modules/util/bar_plot.py +++ b/modules/util/bar_plot.py @@ -2,7 +2,7 @@ import numpy as np import matplotlib.pyplot as plt -def do_plot(group_names, group_values, value_labels, bar_colors, xlabel, ylabel, barWidth=0.1): +def do_plot(group_names, group_values, value_labels, bar_colors, title=None, xlabel=None, ylabel=None, ylim=None, barWidth=0.1): num_groups = len(group_names) num_bars = len(group_values) @@ -11,15 +11,23 @@ def do_plot(group_names, group_values, value_labels, bar_colors, xlabel, ylabel, x = [x + i*barWidth for x in np.arange(num_groups)] bars_x.append(x) + fig, ax = plt.subplots() + if ylim is not None: + ax.set_ylim(ylim) + for k in range(num_bars): plt.bar(bars_x[k], group_values[k], color=bar_colors[k], width=barWidth, edgecolor='white', label=value_labels[k]) # Add xticks on the middle of the group bars - plt.xlabel(xlabel, fontweight='bold') + if xlabel is not None: + plt.xlabel(xlabel, fontweight='bold') plt.xticks([r + barWidth for r in range(num_groups)], group_names) if ylabel is not None: - plt.ylabel('count', fontweight='bold') + plt.ylabel(ylabel, fontweight='bold') + + if title is not None: + plt.title(title, fontweight='bold') # Create legend & Show graphic plt.legend() -- GitLab