Last active
February 19, 2018 23:15
-
-
Save fike/ebfd665c5345c6ba2b5a5a67454d287b to your computer and use it in GitHub Desktop.
matplotlib example.
This file contains hidden or 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 | |
letter_values = (90, 55, 40, 65, 85, 62, 54, 20, 33, 54) | |
letters = {'A': 90, 'B': 55, 'C': 40, 'D': 65, 'E': 85, 'F': 62, 'G': 54, 'H': 20, 'I': 33, 'J': 54} | |
colors = ["#F46716", "#20EA71", "#228FF4", "#F725B8", "#E8F235", | |
"#F9ECC9", "#F9CEAC", "#F7B672", "#F7917B","#FC6B8A"] | |
# create plot | |
index = np.arange(len(letters)) | |
bar_width = 0.35 | |
opacity = 0.8 | |
i = 0 | |
for k, v in letters.items(): | |
plt.barh(k, v, bar_width, | |
alpha=opacity, | |
color=colors[i], | |
label=k) | |
i = i + 1 | |
plt.ylabel('Letters') | |
plt.xlabel('Scores') | |
plt.title('Scores by Letters') | |
plt.yticks(index, letters) | |
plt.legend(loc='lower center', prop={'size':6}, bbox_to_anchor=(0.5,-0.6)) | |
plt.tight_layout(pad=5) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment