.. _lines_bars_and_markers-barh_demo: lines_bars_and_markers example code: barh_demo.py ================================================= .. plot:: /home/tcaswell/source/p/matplotlib/doc/mpl_examples/lines_bars_and_markers/barh_demo.py :: """ Simple demo of a horizontal bar chart. """ import matplotlib.pyplot as plt plt.rcdefaults() import numpy as np import matplotlib.pyplot as plt plt.rcdefaults() 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', color='green', ecolor='black') ax.set_yticks(y_pos) ax.set_yticklabels(people) ax.invert_yaxis() # labels read top-to-bottom ax.set_xlabel('Performance') ax.set_title('How fast do you want to go today?') plt.show() Keywords: python, matplotlib, pylab, example, codex (see :ref:`how-to-search-examples`)