
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/pie_and_polar_charts/polar_error_caps.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. meta::
        :keywords: codex

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_gallery_pie_and_polar_charts_polar_error_caps.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_pie_and_polar_charts_polar_error_caps.py:


=================================
Error bar rendering on polar axis
=================================

Demo of error bar plot in polar coordinates.
Theta error bars are curved lines ended with caps oriented towards the
center.
Radius error bars are straight lines oriented towards center with
perpendicular caps.

.. GENERATED FROM PYTHON SOURCE LINES 12-24

.. code-block:: Python

    import matplotlib.pyplot as plt
    import numpy as np

    theta = np.arange(0, 2 * np.pi, np.pi / 4)
    r = theta / np.pi / 2 + 0.5

    fig = plt.figure(figsize=(10, 10))
    ax = fig.add_subplot(projection='polar')
    ax.errorbar(theta, r, xerr=0.25, yerr=0.1, capsize=7, fmt="o", c="seagreen")
    ax.set_title("Pretty polar error bars")
    plt.show()




.. image-sg:: /gallery/pie_and_polar_charts/images/sphx_glr_polar_error_caps_001.png
   :alt: Pretty polar error bars
   :srcset: /gallery/pie_and_polar_charts/images/sphx_glr_polar_error_caps_001.png, /gallery/pie_and_polar_charts/images/sphx_glr_polar_error_caps_001_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 25-27

Please acknowledge that large theta error bars will be overlapping.
This may reduce readability of the output plot. See example figure below:

.. GENERATED FROM PYTHON SOURCE LINES 27-34

.. code-block:: Python


    fig = plt.figure(figsize=(10, 10))
    ax = fig.add_subplot(projection='polar')
    ax.errorbar(theta, r, xerr=5.25, yerr=0.1, capsize=7, fmt="o", c="darkred")
    ax.set_title("Overlapping theta error bars")
    plt.show()




.. image-sg:: /gallery/pie_and_polar_charts/images/sphx_glr_polar_error_caps_002.png
   :alt: Overlapping theta error bars
   :srcset: /gallery/pie_and_polar_charts/images/sphx_glr_polar_error_caps_002.png, /gallery/pie_and_polar_charts/images/sphx_glr_polar_error_caps_002_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 35-37

On the other hand, large radius error bars will never overlap, they just
lead to unwanted scale in the data, reducing the displayed range.

.. GENERATED FROM PYTHON SOURCE LINES 37-45

.. code-block:: Python


    fig = plt.figure(figsize=(10, 10))
    ax = fig.add_subplot(projection='polar')
    ax.errorbar(theta, r, xerr=0.25, yerr=10.1, capsize=7, fmt="o", c="orangered")
    ax.set_title("Large radius error bars")
    plt.show()





.. image-sg:: /gallery/pie_and_polar_charts/images/sphx_glr_polar_error_caps_003.png
   :alt: Large radius error bars
   :srcset: /gallery/pie_and_polar_charts/images/sphx_glr_polar_error_caps_003.png, /gallery/pie_and_polar_charts/images/sphx_glr_polar_error_caps_003_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 46-60

.. admonition:: References

   The use of the following functions, methods, classes and modules is shown
   in this example:

   - `matplotlib.axes.Axes.errorbar` / `matplotlib.pyplot.errorbar`
   - `matplotlib.projections.polar`

.. tags::

   component: error
   plot-type: errorbar
   plot-type: polar
   level: beginner


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 1.012 seconds)


.. _sphx_glr_download_gallery_pie_and_polar_charts_polar_error_caps.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: polar_error_caps.ipynb <polar_error_caps.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: polar_error_caps.py <polar_error_caps.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: polar_error_caps.zip <polar_error_caps.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
