Skip to content
Snippets Groups Projects
Commit 1e5ed204 authored by tomrink's avatar tomrink
Browse files

snapshot...

parent f5604c9b
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ import numpy as np ...@@ -2,7 +2,7 @@ import numpy as np
import matplotlib.pyplot as plt 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_groups = len(group_names)
num_bars = len(group_values) num_bars = len(group_values)
...@@ -11,15 +11,23 @@ def do_plot(group_names, group_values, value_labels, bar_colors, xlabel, ylabel, ...@@ -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)] x = [x + i*barWidth for x in np.arange(num_groups)]
bars_x.append(x) bars_x.append(x)
fig, ax = plt.subplots()
if ylim is not None:
ax.set_ylim(ylim)
for k in range(num_bars): 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]) 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 # 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) plt.xticks([r + barWidth for r in range(num_groups)], group_names)
if ylabel is not None: 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 # Create legend & Show graphic
plt.legend() plt.legend()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment