.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_lines_bars_and_markers_errorbar_subsample.py: ================== Errorbar Subsample ================== Demo for the errorevery keyword to show data full accuracy data plots with few errorbars. .. image:: /gallery/lines_bars_and_markers/images/sphx_glr_errorbar_subsample_001.png :class: sphx-glr-single-img .. code-block:: python 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 appearance') plt.show() .. _sphx_glr_download_gallery_lines_bars_and_markers_errorbar_subsample.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: errorbar_subsample.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: errorbar_subsample.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature Keywords: matplotlib code example, codex, python plot, pyplot `Gallery generated by Sphinx-Gallery `_