{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Polar plot\n\nDemo of a line plot on a polar axis.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\nimport numpy as np\n\nr = np.arange(0, 2, 0.01)\ntheta = 2 * np.pi * r\n\nfig, ax = plt.subplots(subplot_kw={'projection': 'polar'})\nax.plot(theta, r)\nax.set_rmax(2)\nax.set_rticks([0.5, 1, 1.5, 2]) # Less radial ticks\nax.set_rlabel_position(-22.5) # Move radial labels away from plotted line\nax.grid(True)\n\nax.set_title(\"A line plot on a polar axis\", va='bottom')\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.plot` / `matplotlib.pyplot.plot`\n - `matplotlib.projections.polar`\n - `matplotlib.projections.polar.PolarAxes`\n - `matplotlib.projections.polar.PolarAxes.set_rticks`\n - `matplotlib.projections.polar.PolarAxes.set_rmax`\n - `matplotlib.projections.polar.PolarAxes.set_rlabel_position`\n\n.. tags::\n\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.13.2" } }, "nbformat": 4, "nbformat_minor": 0 }