We're updating the default styles for Matplotlib 2.0

Learn what to expect in the new updates


Previous topic

lines_bars_and_markers Examples

Next topic

lines_bars_and_markers example code: fill_demo.py

This Page

lines_bars_and_markers example code: barh_demo.pyΒΆ

(Source code, png, hires.png, pdf)

Simple demo of a horizontal bar chart.
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.pyplot as plt

# Example data
people = ('Tom', 'Dick', 'Harry', 'Slim', 'Jim')
y_pos = np.arange(len(people))
performance = 3 + 10 * np.random.rand(len(people))
error = np.random.rand(len(people))

plt.barh(y_pos, performance, xerr=error, align='center', alpha=0.4)
plt.yticks(y_pos, people)
plt.title('How fast do you want to go today?')


Keywords: python, matplotlib, pylab, example, codex (see Search examples)