Skip to content

Instantly share code, notes, and snippets.

Last active April 24, 2017 16:54
What would you like to do?
Election presidentielle 2017 - a bar chart created with Python and matplotlib
import matplotlib.pyplot as plt
import numpy as np'seaborn-bright')
fig, ax = plt.subplots()
candidats = ('Marine Le Pen', 'Emmanuel Macron', 'François Fillon', 'Benoît Hamon', 'Jean-Luc Mélenchon')
voter = [21.7,23.9,20,6.3,19.2]
y_pos = np.arange(len(candidats))
couleur = ['#000000', '#dbb243', '#2e42d3', '#e54fe3', '#f23434']
plt.title('Election presidentielle 2017')
plt.ylabel('Vote en %')
plt.ylim(0, 30)
c_rects =, voter, align='center', alpha=0.6, color=couleur)
ax.set_xticklabels(candidats, rotation='vertical')
def autolabel(rects):
for rect in rects:
height = rect.get_height()
ax.text(rect.get_x() + rect.get_width()/2., height + 1,
'%.1f' % float(height),
ha='center', va='bottom')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment