You are reading an old version of the documentation (v1.4.3). For the latest version see https://matplotlib.org/stable/

We're updating the default styles for Matplotlib 2.0

Learn what to expect in the new updates

matplotlib

Previous topic

pylab_examples example code: errorbar_limits.py

Next topic

pylab_examples example code: eventcollection_demo.py

This Page

pylab_examples example code: errorbar_subsample.pyΒΆ

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

../../_images/errorbar_subsample.png
'''
Demo for the errorevery keyword to show data full accuracy data plots with
few errorbars.
'''

import numpy as np
import matplotlib.pyplot as plt

# example data
x = np.arange(0.1, 4, 0.1)
y = np.exp(-x)

# example variable error bar values
yerr = 0.1 + 0.1*np.sqrt(x)


# Now switch to a more OO interface to exercise more features.
fig, axs = plt.subplots(nrows=1, ncols=2, sharex=True)
ax = axs[0]
ax.errorbar(x, y, yerr=yerr)
ax.set_title('all errorbars')

ax = axs[1]
ax.errorbar(x, y, yerr=yerr, errorevery=5)
ax.set_title('only every 5th errorbar')


fig.suptitle('Errorbar subsampling for better visualibility')

plt.show()

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