Tracer un diagramme en bâtons horizontal avec Matplotlib

Pour tracer un diagramme en bâtons horizontal avec Matplotlib il suffit d'utiliser la fonction barh, illustration en reprenant le même exemple que l'article: Diagramme en bâtons avec Matplotlib

[image:barchart-horizontal-matplotlib size=50 caption:Tracer un diagramme en bâtons horizontal avec Matplotlib]

import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()

pos = [1,2,3,4,5,6,7,8,9,10]
height = [8,12,8,5,4,3,2,1,0,0]
width = 1.0

plt.barh(pos, height, width, color='lightcoral' )

plt.xlim(0,max(height)+1)
plt.title('Bar chart horizontal matplotlib')

plt.savefig('barchart_horizontal_matplotlib.png')
plt.show()

Recherches associées