Created
March 15, 2017 10:50
-
-
Save snakers4/f24eb80da8b5a2126818947a19a0a677 to your computer and use it in GitHub Desktop.
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 matplotlib.pyplot as plt | |
import numpy as np | |
plt.figure() | |
languages =['Python', 'SQL', 'Java', 'C++', 'JavaScript'] | |
pos = np.arange(len(languages)) | |
popularity = [56, 39, 34, 34, 29] | |
# change the bar colors to be less bright blue | |
bars = plt.bar(pos, popularity, align='center', linewidth=0, color='lightslategrey') | |
# make one bar, the python bar, a contrasting color | |
bars[0].set_color('#1F77B4') | |
# soften all labels by turning grey | |
plt.xticks(pos, languages, alpha=0.8) | |
plt.ylabel('% Popularity', alpha=0.8) | |
plt.title('Top 5 Languages for Math & Data \nby % popularity on Stack Overflow', alpha=0.8) | |
# remove all the ticks (both axes), and tick labels on the Y axis | |
plt.tick_params(top='off', bottom='off', left='off', right='off', labelleft='off', labelbottom='on') | |
# remove the frame of the chart | |
for spine in plt.gca().spines.values(): | |
spine.set_visible(False) | |
for bar in bars: | |
plt.gca().text(bar.get_x() + bar.get_width()/2, bar.get_height() - 5, str(int(bar.get_height())) + '%', | |
ha='center', color='w', fontsize=11) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment