.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "plot_types/basic/errorbar.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. 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_plot_types_basic_errorbar.py: Error Bars ========== Asymmetric error bars using the :class:`ErrorBar` layer. .. GENERATED FROM PYTHON SOURCE LINES 7-45 .. image-sg:: /plot_types/basic/images/sphx_glr_errorbar_001.png :alt: Error Bars :srcset: /plot_types/basic/images/sphx_glr_errorbar_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy as np from emcpy.plots.plots import LinePlot, ErrorBar from emcpy.plots.create_plots import CreatePlot, CreateFigure rng = np.random.default_rng(42) x = np.linspace(0, 10, 25) y = np.sin(x) + 0.2 * rng.standard_normal(x.size) err_lo = 0.15 + 0.05 * rng.random(x.size) err_hi = 0.20 + 0.05 * rng.random(x.size) p = CreatePlot() layers = [] lp = LinePlot(x, np.sin(x)) lp.linewidth = 2 lp.label = "model" layers.append(lp) eb = ErrorBar(x, y) eb.yerr = [err_lo, err_hi] # asymmetric y errors eb.fmt = "o" eb.capsize = 3 eb.label = "observations" layers.append(eb) p.plot_layers = layers p.add_title("Error Bars") p.add_xlabel("x") p.add_ylabel("value") p.add_grid() p.add_legend(loc="upper right", frameon=False) fig = CreateFigure(1, 1, figsize=(7.5, 4)) fig.plot_list = [p] fig.create_figure() fig.tight_layout() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.076 seconds) .. _sphx_glr_download_plot_types_basic_errorbar.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: errorbar.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: errorbar.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: errorbar.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_