Horizontal bar chart#

This example showcases a simple horizontal bar chart.

How fast do you want to go today?
import matplotlib.pyplot as plt
import numpy as np

# Fixing random state for reproducibility

fig, ax = plt.subplots()

# 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))

ax.barh(y_pos, performance, xerr=error, align='center')
ax.set_yticks(y_pos, labels=people)
ax.invert_yaxis()  # labels read top-to-bottom
ax.set_title('How fast do you want to go today?')


Gallery generated by Sphinx-Gallery