Created
December 9, 2019 11:23
-
-
Save southpolemonkey/e70c4df027d13178da81bc46561d6e42 to your computer and use it in GitHub Desktop.
Create multiple columns barchart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
# data to plot | |
n_groups = 4 | |
means_frank = (90, 55, 40, 65) | |
means_guido = (85, 62, 54, 20) | |
# create plot | |
fig, ax = plt.subplots() | |
index = np.arange(n_groups) | |
bar_width = 0.35 | |
opacity = 0.8 | |
rects1 = plt.bar(index, means_frank, bar_width, | |
alpha=opacity, | |
color='b', | |
label='Frank') | |
rects2 = plt.bar(index + bar_width, means_guido, bar_width, | |
alpha=opacity, | |
color='g', | |
label='Guido') | |
plt.xlabel('Person') | |
plt.ylabel('Scores') | |
plt.title('Scores by person') | |
plt.xticks(index + bar_width, ('A', 'B', 'C', 'D')) | |
plt.legend() | |
plt.tight_layout() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment