{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Annotate polar plots\n\nThis example shows how to create an annotation on a polar graph.\n\nFor a complete overview of the annotation capabilities, also see the\n`annotations`.\n\n.. redirect-from:: /gallery/pyplots/annotation_polar\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\nimport numpy as np\n\nfig = plt.figure()\nax = fig.add_subplot(projection='polar')\nr = np.arange(0, 1, 0.001)\ntheta = 2 * 2*np.pi * r\nline, = ax.plot(theta, r, color='#ee8d18', lw=3)\n\nind = 800\nthisr, thistheta = r[ind], theta[ind]\nax.plot([thistheta], [thisr], 'o')\nax.annotate('a polar annotation',\n xy=(thistheta, thisr), # theta, radius\n xytext=(0.05, 0.05), # fraction, fraction\n textcoords='figure fraction',\n arrowprops=dict(facecolor='black', shrink=0.05),\n horizontalalignment='left',\n verticalalignment='bottom',\n )\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.projections.polar`\n - `matplotlib.axes.Axes.annotate` / `matplotlib.pyplot.annotate`\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 }