{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Error bar rendering on polar axis\n\nDemo of error bar plot in polar coordinates.\nTheta error bars are curved lines ended with caps oriented towards the\ncenter.\nRadius error bars are straight lines oriented towards center with\nperpendicular caps.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\nimport numpy as np\n\ntheta = np.arange(0, 2 * np.pi, np.pi / 4)\nr = theta / np.pi / 2 + 0.5\n\nfig = plt.figure(figsize=(10, 10))\nax = fig.add_subplot(projection='polar')\nax.errorbar(theta, r, xerr=0.25, yerr=0.1, capsize=7, fmt=\"o\", c=\"seagreen\")\nax.set_title(\"Pretty polar error bars\")\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Please acknowledge that large theta error bars will be overlapping.\nThis may reduce readability of the output plot. See example figure below:\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "fig = plt.figure(figsize=(10, 10))\nax = fig.add_subplot(projection='polar')\nax.errorbar(theta, r, xerr=5.25, yerr=0.1, capsize=7, fmt=\"o\", c=\"darkred\")\nax.set_title(\"Overlapping theta error bars\")\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "On the other hand, large radius error bars will never overlap, they just\nlead to unwanted scale in the data, reducing the displayed range.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "fig = plt.figure(figsize=(10, 10))\nax = fig.add_subplot(projection='polar')\nax.errorbar(theta, r, xerr=0.25, yerr=10.1, capsize=7, fmt=\"o\", c=\"orangered\")\nax.set_title(\"Large radius error bars\")\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        ".. admonition:: References\n\n   The use of the following functions, methods, classes and modules is shown\n   in this example:\n\n   - `matplotlib.axes.Axes.errorbar` / `matplotlib.pyplot.errorbar`\n   - `matplotlib.projections.polar`\n\n.. tags::\n\n   component: error\n   plot-type: errorbar\n   plot-type: polar\n   level: beginner\n\n"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.14.6"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}