{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n.. redirect-from:: /tutorials/advanced/transforms_tutorial\n\n\n# Transformations Tutorial\n\nLike any graphics packages, Matplotlib is built on top of a transformation\nframework to easily move between coordinate systems, the userland *data*\ncoordinate system, the *axes* coordinate system, the *figure* coordinate\nsystem, and the *display* coordinate system. In 95% of your plotting, you\nwon't need to think about this, as it happens under the hood, but as you push\nthe limits of custom figure generation, it helps to have an understanding of\nthese objects, so you can reuse the existing transformations Matplotlib makes\navailable to you, or create your own (see :mod:`matplotlib.transforms`). The\ntable below summarizes some useful coordinate systems, a description of each\nsystem, and the transformation object for going from each coordinate system to\nthe *display* coordinates. In the \"Transformation Object\" column, ``ax`` is a\n:class:`~matplotlib.axes.Axes` instance, ``fig`` is a\n:class:`~matplotlib.figure.Figure` instance, and ``subfigure`` is a\n:class:`~matplotlib.figure.SubFigure` instance.\n\n\n+----------------+-----------------------------------+-----------------------------+\n|Coordinate |Description |Transformation object |\n|system | |from system to display |\n+================+===================================+=============================+\n|*data* |The coordinate system of the data |``ax.transData`` |\n| |in the Axes. | |\n+----------------+-----------------------------------+-----------------------------+\n|*axes* |The coordinate system of the |``ax.transAxes`` |\n| |`~matplotlib.axes.Axes`; (0, 0) | |\n| |is bottom left of the Axes, and | |\n| |(1, 1) is top right of the Axes. | |\n+----------------+-----------------------------------+-----------------------------+\n|*subfigure* |The coordinate system of the |``subfigure.transSubfigure`` |\n| |`.SubFigure`; (0, 0) is bottom left| |\n| |of the subfigure, and (1, 1) is top| |\n| |right of the subfigure. If a | |\n| |figure has no subfigures, this is | |\n| |the same as ``transFigure``. | |\n+----------------+-----------------------------------+-----------------------------+\n|*figure* |The coordinate system of the |``fig.transFigure`` |\n| |`.Figure`; (0, 0) is bottom left | |\n| |of the figure, and (1, 1) is top | |\n| |right of the figure. | |\n+----------------+-----------------------------------+-----------------------------+\n|*figure-inches* |The coordinate system of the |``fig.dpi_scale_trans`` |\n| |`.Figure` in inches; (0, 0) is | |\n| |bottom left of the figure, and | |\n| |(width, height) is the top right | |\n| |of the figure in inches. | |\n+----------------+-----------------------------------+-----------------------------+\n|*xaxis*, |Blended coordinate systems, using |``ax.get_xaxis_transform()``,|\n|*yaxis* |data coordinates on one direction |``ax.get_yaxis_transform()`` |\n| |and axes coordinates on the other. | |\n+----------------+-----------------------------------+-----------------------------+\n|*display* |The native coordinate system of the|`None`, or |\n| |output ; (0, 0) is the bottom left |`.IdentityTransform()` |\n| |of the window, and (width, height) | |\n| |is top right of the output in | |\n| |\"display units\". | |\n| | | |\n| |The exact interpretation of the | |\n| |units depends on the back end. For | |\n| |example it is pixels for Agg and | |\n| |points for svg/pdf. | |\n+----------------+-----------------------------------+-----------------------------+\n\nThe `~matplotlib.transforms.Transform` objects are naive to the source and\ndestination coordinate systems, however the objects referred to in the table\nabove are constructed to take inputs in their coordinate system, and transform\nthe input to the *display* coordinate system. That is why the *display*\ncoordinate system has `None` for the \"Transformation Object\" column -- it\nalready is in *display* coordinates. The naming and destination conventions\nare an aid to keeping track of the available \"standard\" coordinate systems and\ntransforms.\n\nThe transformations also know how to invert themselves (via\n`.Transform.inverted`) to generate a transform from output coordinate system\nback to the input coordinate system. For example, ``ax.transData`` converts\nvalues in data coordinates to display coordinates and\n``ax.transData.inverted()`` is a :class:`matplotlib.transforms.Transform` that\ngoes from display coordinates to data coordinates. This is particularly useful\nwhen processing events from the user interface, which typically occur in\ndisplay space, and you want to know where the mouse click or key-press occurred\nin your *data* coordinate system.\n\nNote that specifying the position of Artists in *display* coordinates may\nchange their relative location if the ``dpi`` or size of the figure changes.\nThis can cause confusion when printing or changing screen resolution, because\nthe object can change location and size. Therefore, it is most common for\nartists placed in an Axes or figure to have their transform set to something\n*other* than the `~.transforms.IdentityTransform()`; the default when an artist\nis added to an Axes using `~.axes.Axes.add_artist` is for the transform to be\n``ax.transData`` so that you can work and think in *data* coordinates and let\nMatplotlib take care of the transformation to *display*.\n\n\n## Data coordinates\n\nLet's start with the most commonly used coordinate, the *data* coordinate\nsystem. Whenever you add data to the Axes, Matplotlib updates the datalimits,\nmost commonly updated with the :meth:`~matplotlib.axes.Axes.set_xlim` and\n:meth:`~matplotlib.axes.Axes.set_ylim` methods. For example, in the figure\nbelow, the data limits stretch from 0 to 10 on the x-axis, and -1 to 1 on the\ny-axis.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\nimport numpy as np\n\nimport matplotlib.patches as mpatches\n\nx = np.arange(0, 10, 0.005)\ny = np.exp(-x/2.) * np.sin(2*np.pi*x)\n\nfig, ax = plt.subplots()\nax.plot(x, y)\nax.set_xlim(0, 10)\nax.set_ylim(-1, 1)\n\nplt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can use the ``ax.transData`` instance to transform from your\n*data* to your *display* coordinate system, either a single point or a\nsequence of points as shown below:\n\n.. sourcecode:: ipython\n\n In [14]: type(ax.transData)\n Out[14]: \n\n In [15]: ax.transData.transform((5, 0))\n Out[15]: array([ 335.175, 247. ])\n\n In [16]: ax.transData.transform([(5, 0), (1, 2)])\n Out[16]:\n array([[ 335.175, 247. ],\n [ 132.435, 642.2 ]])\n\nYou can use the :meth:`~matplotlib.transforms.Transform.inverted`\nmethod to create a transform which will take you from *display* to *data*\ncoordinates:\n\n.. sourcecode:: ipython\n\n In [41]: inv = ax.transData.inverted()\n\n In [42]: type(inv)\n Out[42]: \n\n In [43]: inv.transform((335.175, 247.))\n Out[43]: array([ 5., 0.])\n\nIf your are typing along with this tutorial, the exact values of the\n*display* coordinates may differ if you have a different window size or\ndpi setting. Likewise, in the figure below, the display labeled\npoints are probably not the same as in the ipython session because the\ndocumentation figure size defaults are different.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "x = np.arange(0, 10, 0.005)\ny = np.exp(-x/2.) * np.sin(2*np.pi*x)\n\nfig, ax = plt.subplots()\nax.plot(x, y)\nax.set_xlim(0, 10)\nax.set_ylim(-1, 1)\n\nxdata, ydata = 5, 0\n# This computing the transform now, if anything\n# (figure size, dpi, axes placement, data limits, scales..)\n# changes re-calling transform will get a different value.\nxdisplay, ydisplay = ax.transData.transform((xdata, ydata))\n\nbbox = dict(boxstyle=\"round\", fc=\"0.8\")\narrowprops = dict(\n arrowstyle=\"->\",\n connectionstyle=\"angle,angleA=0,angleB=90,rad=10\")\n\noffset = 72\nax.annotate(f'data = ({xdata:.1f}, {ydata:.1f})',\n (xdata, ydata), xytext=(-2*offset, offset), textcoords='offset points',\n bbox=bbox, arrowprops=arrowprops)\n\ndisp = ax.annotate(f'display = ({xdisplay:.1f}, {ydisplay:.1f})',\n (xdisplay, ydisplay), xytext=(0.5*offset, -offset),\n xycoords='figure pixels',\n textcoords='offset points',\n bbox=bbox, arrowprops=arrowprops)\n\nplt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Warning

If you run the source code in the example above in a GUI backend,\n you may also find that the two arrows for the *data* and *display*\n annotations do not point to exactly the same point. This is because\n the display point was computed before the figure was displayed, and\n the GUI backend may slightly resize the figure when it is created.\n The effect is more pronounced if you resize the figure yourself.\n This is one good reason why you rarely want to work in *display*\n space, but you can connect to the ``'on_draw'``\n :class:`~matplotlib.backend_bases.Event` to update *figure*\n coordinates on figure draws; see `event-handling`.

\n\nWhen you change the x or y limits of your axes, the data limits are\nupdated so the transformation yields a new display point. Note that\nwhen we just change the ylim, only the y-display coordinate is\naltered, and when we change the xlim too, both are altered. More on\nthis later when we talk about the\n:class:`~matplotlib.transforms.Bbox`.\n\n.. sourcecode:: ipython\n\n In [54]: ax.transData.transform((5, 0))\n Out[54]: array([ 335.175, 247. ])\n\n In [55]: ax.set_ylim(-1, 2)\n Out[55]: (-1, 2)\n\n In [56]: ax.transData.transform((5, 0))\n Out[56]: array([ 335.175 , 181.13333333])\n\n In [57]: ax.set_xlim(10, 20)\n Out[57]: (10, 20)\n\n In [58]: ax.transData.transform((5, 0))\n Out[58]: array([-171.675 , 181.13333333])\n\n\n\n## Axes coordinates\n\nAfter the *data* coordinate system, *axes* is probably the second most\nuseful coordinate system. Here the point (0, 0) is the bottom left of\nyour Axes or subplot, (0.5, 0.5) is the center, and (1.0, 1.0) is the top\nright. You can also refer to points outside the range, so (-0.1, 1.1)\nis to the left and above your Axes. This coordinate system is extremely\nuseful when placing text in your Axes, because you often want a text bubble\nin a fixed, location, e.g., the upper left of the Axes pane, and have that\nlocation remain fixed when you pan or zoom. Here is a simple example that\ncreates four panels and labels them 'A', 'B', 'C', 'D' as you often see in\njournals. A more sophisticated approach for such labeling is presented at\n:doc:`/gallery/text_labels_and_annotations/label_subplots`.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "fig = plt.figure()\nfor i, label in enumerate(('A', 'B', 'C', 'D')):\n ax = fig.add_subplot(2, 2, i+1)\n ax.text(0.05, 0.95, label, transform=ax.transAxes,\n fontsize=16, fontweight='bold', va='top')\n\nplt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can also make lines or patches in the *axes* coordinate system, but\nthis is less useful in my experience than using ``ax.transAxes`` for\nplacing text. Nonetheless, here is a silly example which plots some\nrandom dots in data space, and overlays a semi-transparent\n:class:`~matplotlib.patches.Circle` centered in the middle of the Axes\nwith a radius one quarter of the Axes -- if your Axes does not\npreserve aspect ratio (see :meth:`~matplotlib.axes.Axes.set_aspect`),\nthis will look like an ellipse. Use the pan/zoom tool to move around,\nor manually change the data xlim and ylim, and you will see the data\nmove, but the circle will remain fixed because it is not in *data*\ncoordinates and will always remain at the center of the Axes.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "fig, ax = plt.subplots()\nx, y = 10*np.random.rand(2, 1000)\nax.plot(x, y, 'go', alpha=0.2) # plot some data in data coordinates\n\ncirc = mpatches.Circle((0.5, 0.5), 0.25, transform=ax.transAxes,\n facecolor='blue', alpha=0.75)\nax.add_patch(circ)\nplt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n## Blended transformations\n\nDrawing in *blended* coordinate spaces which mix *axes* with *data*\ncoordinates is extremely useful, for example to create a horizontal\nspan which highlights some region of the y-data but spans across the\nx-axis regardless of the data limits, pan or zoom level, etc. In fact\nthese blended lines and spans are so useful, we have built-in\nfunctions to make them easy to plot (see\n:meth:`~matplotlib.axes.Axes.axhline`,\n:meth:`~matplotlib.axes.Axes.axvline`,\n:meth:`~matplotlib.axes.Axes.axhspan`,\n:meth:`~matplotlib.axes.Axes.axvspan`) but for didactic purposes we\nwill implement the horizontal span here using a blended\ntransformation. This trick only works for separable transformations,\nlike you see in normal Cartesian coordinate systems, but not on\ninseparable transformations like the\n:class:`~matplotlib.projections.polar.PolarAxes.PolarTransform`.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.transforms as transforms\n\nfig, ax = plt.subplots()\nx = np.random.randn(1000)\n\nax.hist(x, 30)\nax.set_title(r'$\\sigma=1 \\/ \\dots \\/ \\sigma=2$', fontsize=16)\n\n# the x coords of this transformation are data, and the y coord are axes\ntrans = transforms.blended_transform_factory(\n ax.transData, ax.transAxes)\n# highlight the 1..2 stddev region with a span.\n# We want x to be in data coordinates and y to span from 0..1 in axes coords.\nrect = mpatches.Rectangle((1, 0), width=1, height=1, transform=trans,\n color='yellow', alpha=0.5)\nax.add_patch(rect)\n\nplt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Note

The blended transformations where x is in *data* coords and y in *axes*\n coordinates is so useful that we have helper methods to return the\n versions Matplotlib uses internally for drawing ticks, ticklabels, etc.\n The methods are :meth:`matplotlib.axes.Axes.get_xaxis_transform` and\n :meth:`matplotlib.axes.Axes.get_yaxis_transform`. So in the example\n above, the call to\n :meth:`~matplotlib.transforms.blended_transform_factory` can be\n replaced by ``get_xaxis_transform``::\n\n trans = ax.get_xaxis_transform()

\n\n\n## Plotting in physical coordinates\n\nSometimes we want an object to be a certain physical size on the plot.\nHere we draw the same circle as above, but in physical coordinates. If done\ninteractively, you can see that changing the size of the figure does\nnot change the offset of the circle from the lower-left corner,\ndoes not change its size, and the circle remains a circle regardless of\nthe aspect ratio of the Axes.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=(5, 4))\nx, y = 10*np.random.rand(2, 1000)\nax.plot(x, y*10., 'go', alpha=0.2) # plot some data in data coordinates\n# add a circle in fixed-coordinates\ncirc = mpatches.Circle((2.5, 2), 1.0, transform=fig.dpi_scale_trans,\n facecolor='blue', alpha=0.75)\nax.add_patch(circ)\nplt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If we change the figure size, the circle does not change its absolute\nposition and is cropped.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=(7, 2))\nx, y = 10*np.random.rand(2, 1000)\nax.plot(x, y*10., 'go', alpha=0.2) # plot some data in data coordinates\n# add a circle in fixed-coordinates\ncirc = mpatches.Circle((2.5, 2), 1.0, transform=fig.dpi_scale_trans,\n facecolor='blue', alpha=0.75)\nax.add_patch(circ)\nplt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Another use is putting a patch with a set physical dimension around a\ndata point on the Axes. Here we add together two transforms. The\nfirst sets the scaling of how large the ellipse should be and the second\nsets its position. The ellipse is then placed at the origin, and then\nwe use the helper transform :class:`~matplotlib.transforms.ScaledTranslation`\nto move it\nto the right place in the ``ax.transData`` coordinate system.\nThis helper is instantiated with::\n\n trans = ScaledTranslation(xt, yt, scale_trans)\n\nwhere *xt* and *yt* are the translation offsets, and *scale_trans* is\na transformation which scales *xt* and *yt* at transformation time\nbefore applying the offsets.\n\nNote the use of the plus operator on the transforms below.\nThis code says: first apply the scale transformation ``fig.dpi_scale_trans``\nto make the ellipse the proper size, but still centered at (0, 0),\nand then translate the data to ``xdata[0]`` and ``ydata[0]`` in data space.\n\nIn interactive use, the ellipse stays the same size even if the\naxes limits are changed via zoom.\n\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "fig, ax = plt.subplots()\nxdata, ydata = (0.2, 0.7), (0.5, 0.5)\nax.plot(xdata, ydata, \"o\")\nax.set_xlim((0, 1))\n\ntrans = (fig.dpi_scale_trans +\n transforms.ScaledTranslation(xdata[0], ydata[0], ax.transData))\n\n# plot an ellipse around the point that is 150 x 130 points in diameter...\ncircle = mpatches.Ellipse((0, 0), 150/72, 130/72, angle=40,\n fill=None, transform=trans)\nax.add_patch(circle)\nplt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Note

The order of transformation matters. Here the ellipse\n is given the right dimensions in display space *first* and then moved\n in data space to the correct spot.\n If we had done the ``ScaledTranslation`` first, then\n ``xdata[0]`` and ``ydata[0]`` would\n first be transformed to *display* coordinates (``[ 358.4 475.2]`` on\n a 200-dpi monitor) and then those coordinates\n would be scaled by ``fig.dpi_scale_trans`` pushing the center of\n the ellipse well off the screen (i.e. ``[ 71680. 95040.]``).

\n\n\n## Using offset transforms to create a shadow effect\n\nAnother use of :class:`~matplotlib.transforms.ScaledTranslation` is to create\na new transformation that is\noffset from another transformation, e.g., to place one object shifted a\nbit relative to another object. Typically, you want the shift to be in\nsome physical dimension, like points or inches rather than in *data*\ncoordinates, so that the shift effect is constant at different zoom\nlevels and dpi settings.\n\nOne use for an offset is to create a shadow effect, where you draw one\nobject identical to the first just to the right of it, and just below\nit, adjusting the zorder to make sure the shadow is drawn first and\nthen the object it is shadowing above it.\n\nHere we apply the transforms in the *opposite* order to the use of\n:class:`~matplotlib.transforms.ScaledTranslation` above. The plot is\nfirst made in data coordinates (``ax.transData``) and then shifted by\n``dx`` and ``dy`` points using ``fig.dpi_scale_trans``. (In typography,\na [point](https://en.wikipedia.org/wiki/Point_%28typography%29) is\n1/72 inches, and by specifying your offsets in points, your figure\nwill look the same regardless of the dpi resolution it is saved in.)\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "fig, ax = plt.subplots()\n\n# make a simple sine wave\nx = np.arange(0., 2., 0.01)\ny = np.sin(2*np.pi*x)\nline, = ax.plot(x, y, lw=3, color='blue')\n\n# shift the object over 2 points, and down 2 points\ndx, dy = 2/72., -2/72.\noffset = transforms.ScaledTranslation(dx, dy, fig.dpi_scale_trans)\nshadow_transform = ax.transData + offset\n\n# now plot the same data with our offset transform;\n# use the zorder to make sure we are below the line\nax.plot(x, y, lw=3, color='gray',\n transform=shadow_transform,\n zorder=0.5*line.get_zorder())\n\nax.set_title('creating a shadow effect with an offset transform')\nplt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Note

The dpi and inches offset is a\n common-enough use case that we have a special helper function to\n create it in :func:`matplotlib.transforms.offset_copy`, which returns\n a new transform with an added offset. So above we could have done::\n\n shadow_transform = transforms.offset_copy(ax.transData,\n fig, dx, dy, units='inches')

\n\n\n\n## The transformation pipeline\n\nThe ``ax.transData`` transform we have been working with in this\ntutorial is a composite of three different transformations that\ncomprise the transformation pipeline from *data* -> *display*\ncoordinates. Michael Droettboom implemented the transformations\nframework, taking care to provide a clean API that segregated the\nnonlinear projections and scales that happen in polar and logarithmic\nplots, from the linear affine transformations that happen when you pan\nand zoom. There is an efficiency here, because you can pan and zoom\nin your Axes which affects the affine transformation, but you may not\nneed to compute the potentially expensive nonlinear scales or\nprojections on simple navigation events. It is also possible to\nmultiply affine transformation matrices together, and then apply them\nto coordinates in one step. This is not true of all possible\ntransformations.\n\n\nHere is how the ``ax.transData`` instance is defined in the basic\nseparable axis :class:`~matplotlib.axes.Axes` class::\n\n self.transData = self.transScale + (self.transLimits + self.transAxes)\n\nWe've been introduced to the ``transAxes`` instance above in\n`axes-coords`, which maps the (0, 0), (1, 1) corners of the\nAxes or subplot bounding box to *display* space, so let's look at\nthese other two pieces.\n\n``self.transLimits`` is the transformation that takes you from\n*data* to *axes* coordinates; i.e., it maps your view xlim and ylim\nto the unit space of the Axes (and ``transAxes`` then takes that unit\nspace to display space). We can see this in action here\n\n.. sourcecode:: ipython\n\n In [80]: ax = plt.subplot()\n\n In [81]: ax.set_xlim(0, 10)\n Out[81]: (0, 10)\n\n In [82]: ax.set_ylim(-1, 1)\n Out[82]: (-1, 1)\n\n In [84]: ax.transLimits.transform((0, -1))\n Out[84]: array([ 0., 0.])\n\n In [85]: ax.transLimits.transform((10, -1))\n Out[85]: array([ 1., 0.])\n\n In [86]: ax.transLimits.transform((10, 1))\n Out[86]: array([ 1., 1.])\n\n In [87]: ax.transLimits.transform((5, 0))\n Out[87]: array([ 0.5, 0.5])\n\nand we can use this same inverted transformation to go from the unit\n*axes* coordinates back to *data* coordinates.\n\n.. sourcecode:: ipython\n\n In [90]: inv.transform((0.25, 0.25))\n Out[90]: array([ 2.5, -0.5])\n\nThe final piece is the ``self.transScale`` attribute, which is\nresponsible for the optional non-linear scaling of the data, e.g., for\nlogarithmic axes. When an Axes is initially setup, this is just set to\nthe identity transform, since the basic Matplotlib axes has linear\nscale, but when you call a logarithmic scaling function like\n:meth:`~matplotlib.axes.Axes.semilogx` or explicitly set the scale to\nlogarithmic with :meth:`~matplotlib.axes.Axes.set_xscale`, then the\n``ax.transScale`` attribute is set to handle the nonlinear projection.\nThe scales transforms are properties of the respective ``xaxis`` and\n``yaxis`` :class:`~matplotlib.axis.Axis` instances. For example, when\nyou call ``ax.set_xscale('log')``, the xaxis updates its scale to a\n:class:`matplotlib.scale.LogScale` instance.\n\nFor non-separable axes the PolarAxes, there is one more piece to\nconsider, the projection transformation. The ``transData``\n:class:`matplotlib.projections.polar.PolarAxes` is similar to that for\nthe typical separable matplotlib Axes, with one additional piece\n``transProjection``::\n\n self.transData = (\n self.transScale + self.transShift + self.transProjection +\n (self.transProjectionAffine + self.transWedge + self.transAxes))\n\n``transProjection`` handles the projection from the space,\ne.g., latitude and longitude for map data, or radius and theta for polar\ndata, to a separable Cartesian coordinate system. There are several\nprojection examples in the :mod:`matplotlib.projections` package, and the\nbest way to learn more is to open the source for those packages and\nsee how to make your own, since Matplotlib supports extensible axes\nand projections. Michael Droettboom has provided a nice tutorial\nexample of creating a Hammer projection axes; see\n:doc:`/gallery/misc/custom_projection`.\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 }