|
| 1 | +""" |
| 2 | +Non-separable transforms that map from data space to screen space. |
| 3 | +
|
| 4 | +Projections are defined as `~.axes.Axes` subclasses. They include the |
| 5 | +following elements: |
| 6 | +
|
| 7 | +- A transformation from data coordinates into display coordinates. |
| 8 | +
|
| 9 | +- An inverse of that transformation. This is used, for example, to convert |
| 10 | + mouse positions from screen space back into data space. |
| 11 | +
|
| 12 | +- Transformations for the gridlines, ticks and ticklabels. Custom projections |
| 13 | + will often need to place these elements in special locations, and Matplotlib |
| 14 | + has a facility to help with doing so. |
| 15 | +
|
| 16 | +- Setting up default values (overriding `~.axes.Axes.cla`), since the defaults |
| 17 | + for a rectilinear axes may not be appropriate. |
| 18 | +
|
| 19 | +- Defining the shape of the axes, for example, an elliptical axes, that will be |
| 20 | + used to draw the background of the plot and for clipping any data elements. |
| 21 | +
|
| 22 | +- Defining custom locators and formatters for the projection. For example, in |
| 23 | + a geographic projection, it may be more convenient to display the grid in |
| 24 | + degrees, even if the data is in radians. |
| 25 | +
|
| 26 | +- Set up interactive panning and zooming. This is left as an "advanced" |
| 27 | + feature left to the reader, but there is an example of this for polar plots |
| 28 | + in `matplotlib.projections.polar`. |
| 29 | +
|
| 30 | +- Any additional methods for additional convenience or features. |
| 31 | +
|
| 32 | +Once the projection axes is defined, it can be used in one of two ways: |
| 33 | +
|
| 34 | +- By defining the class attribute ``name``, the projection axes can be |
| 35 | + registered with `matplotlib.projections.register_projection` and subsequently |
| 36 | + simply invoked by name:: |
| 37 | +
|
| 38 | + fig.add_subplot(projection="my_proj_name") |
| 39 | +
|
| 40 | +- For more complex, parameterisable projections, a generic "projection" object |
| 41 | + may be defined which includes the method ``_as_mpl_axes``. ``_as_mpl_axes`` |
| 42 | + should take no arguments and return the projection's axes subclass and a |
| 43 | + dictionary of additional arguments to pass to the subclass' ``__init__`` |
| 44 | + method. Subsequently a parameterised projection can be initialised with:: |
| 45 | +
|
| 46 | + fig.add_subplot(projection=MyProjection(param1=param1_value)) |
| 47 | +
|
| 48 | + where MyProjection is an object which implements a ``_as_mpl_axes`` method. |
| 49 | +
|
| 50 | +A full-fledged and heavily annotated example is in |
| 51 | +:doc:`/gallery/misc/custom_projection`. The polar plot functionality in |
| 52 | +`matplotlib.projections.polar` may also be of interest. |
| 53 | +""" |
| 54 | + |
1 | 55 | from .. import axes, docstring
|
2 | 56 | from .geo import AitoffAxes, HammerAxes, LambertAxes, MollweideAxes
|
3 | 57 | from .polar import PolarAxes
|
|
0 commit comments