.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/lines_bars_and_markers/errorbar_subsample.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. meta:: :keywords: codex .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_lines_bars_and_markers_errorbar_subsample.py: ==================== Errorbar subsampling ==================== The parameter *errorevery* of `.Axes.errorbar` can be used to draw error bars only on a subset of data points. This is particularly useful if there are many data points with similar errors. .. GENERATED FROM PYTHON SOURCE LINES 10-41 .. image-sg:: /gallery/lines_bars_and_markers/images/sphx_glr_errorbar_subsample_001.png :alt: Errorbar subsampling, all errorbars, only every 6th errorbar, second series shifted by 3 :srcset: /gallery/lines_bars_and_markers/images/sphx_glr_errorbar_subsample_001.png, /gallery/lines_bars_and_markers/images/sphx_glr_errorbar_subsample_001_2_00x.png 2.00x :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np # example data x = np.arange(0.1, 4, 0.1) y1 = np.exp(-1.0 * x) y2 = np.exp(-0.5 * x) # example variable error bar values y1err = 0.1 + 0.1 * np.sqrt(x) y2err = 0.1 + 0.1 * np.sqrt(x/2) fig, (ax0, ax1, ax2) = plt.subplots(nrows=1, ncols=3, sharex=True, figsize=(12, 6)) ax0.set_title('all errorbars') ax0.errorbar(x, y1, yerr=y1err) ax0.errorbar(x, y2, yerr=y2err) ax1.set_title('only every 6th errorbar') ax1.errorbar(x, y1, yerr=y1err, errorevery=6) ax1.errorbar(x, y2, yerr=y2err, errorevery=6) ax2.set_title('second series shifted by 3') ax2.errorbar(x, y1, yerr=y1err, errorevery=(0, 6)) ax2.errorbar(x, y2, yerr=y2err, errorevery=(3, 6)) fig.suptitle('Errorbar subsampling') plt.show() .. _sphx_glr_download_gallery_lines_bars_and_markers_errorbar_subsample.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: errorbar_subsample.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: errorbar_subsample.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_