import matplotlib.pyplot as plt<br>import numpy as np<br><br><br>labels = ['G1', 'G2', 'G3', 'G4', 'G5']<br>men_means = [20, 34, 30, 35, 27]<br>women_means = [25, 32, 34, 20, 25]<br><br>x = np.arange(len(labels)) # the label locations<br>width = 0.35 # the width of the bars<br><br>fig, ax = plt.subplots()<br>rects1 = ax.bar(x - width/2, men_means, width, label='Men')<br>rects2 = ax.bar(x + width/2, women_means, width, label='Women')<br><br># Add some text for labels, title and custom x-axis tick labels, etc.<br>ax.set_ylabel('Scores')<br>ax.set_title('Scores by group and gender')<br>ax.set_xticks(x, labels)<br>ax.legend()<br><br>ax.bar_label(rects1, padding=3)<br>ax.bar_label(rects2, padding=3)<br><br>fig.tight_layout()<br><br>plt.show()
子主题