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

    Click :ref:`here <sphx_glr_download_gallery_pie_and_polar_charts_polar_bar.py>` to download the full example code
.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_pie_and_polar_charts_polar_bar.py:


=======================
Pie chart on polar axis
=======================

Demo of bar plot on a polar axis.



.. code-block:: python

    import numpy as np
    import matplotlib.pyplot as plt


    # Fixing random state for reproducibility
    np.random.seed(19680801)

    # Compute pie slices
    N = 20
    theta = np.linspace(0.0, 2 * np.pi, N, endpoint=False)
    radii = 10 * np.random.rand(N)
    width = np.pi / 4 * np.random.rand(N)

    ax = plt.subplot(111, projection='polar')
    bars = ax.bar(theta, radii, width=width, bottom=0.0)

    # Use custom colors and opacity
    for r, bar in zip(radii, bars):
        bar.set_facecolor(plt.cm.viridis(r / 10.))
        bar.set_alpha(0.5)

    plt.show()




.. image:: /gallery/pie_and_polar_charts/images/sphx_glr_polar_bar_001.png
    :class: sphx-glr-single-img




------------

References
""""""""""

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



.. code-block:: python


    import matplotlib
    matplotlib.axes.Axes.bar
    matplotlib.pyplot.bar
    matplotlib.projections.polar







.. _sphx_glr_download_gallery_pie_and_polar_charts_polar_bar.py:


.. only :: html

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



  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

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


.. only:: html

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

    Keywords: matplotlib code example, codex, python plot, pyplot
    `Gallery generated by Sphinx-Gallery
    <https://sphinx-gallery.readthedocs.io>`_
