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 pltimport numpy as npfig = 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.0plt.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
| Liens | Site |
|---|---|
| Diagramme en bâtons avec Matplotlib | science-emergence.com |
| lines_bars_and_markers example code: barh_demo.py | matplotlib.org |
| Horizontal bar chart with Python (matplotlib) | youtube |
| matplotlib chart - creating horizontal bar chart | stackoverflow |
| pylab_examples example code: barh_demo.py | matplotlib.org |
