|
11 | 11 | the limits of custom figure generation, it helps to have an understanding of |
12 | 12 | these objects so you can reuse the existing transformations Matplotlib makes |
13 | 13 | available to you, or create your own (see :mod:`matplotlib.transforms`). The |
14 | | -table below summarizes some useful coordinate systems, a description of |
15 | | -each system, and the transformation object for going from each coordinate |
16 | | -system to the *display* coordinates. In the "Transformation Object" column, |
17 | | -``ax`` is a :class:`~matplotlib.axes.Axes` instance, and ``fig`` is a |
18 | | -:class:`~matplotlib.figure.Figure` instance. |
19 | | -
|
20 | | -+----------------+-----------------------------------+-----------------------------+ |
21 | | -|Coordinate |Description |Transformation object | |
22 | | -|system | |from system to display | |
23 | | -+================+===================================+=============================+ |
24 | | -|"data" |The coordinate system of the data |``ax.transData`` | |
25 | | -| |in the Axes. | | |
26 | | -+----------------+-----------------------------------+-----------------------------+ |
27 | | -|"axes" |The coordinate system of the |``ax.transAxes`` | |
28 | | -| |`~matplotlib.axes.Axes`; (0, 0) | | |
29 | | -| |is bottom left of the axes, and | | |
30 | | -| |(1, 1) is top right of the axes. | | |
31 | | -+----------------+-----------------------------------+-----------------------------+ |
32 | | -|"subfigure" |The coordinate system of the |``subfigure.transSubfigure`` | |
33 | | -| |`.SubFigure`; (0, 0) is bottom left| | |
34 | | -| |of the subfigure, and (1, 1) is top| | |
35 | | -| |right of the subfigure. If a | | |
36 | | -| |figure has no subfigures, this is | | |
37 | | -| |the same as ``transFigure``. | | |
38 | | -+----------------+-----------------------------------+-----------------------------+ |
39 | | -|"figure" |The coordinate system of the |``fig.transFigure`` | |
40 | | -| |`.Figure`; (0, 0) is bottom left | | |
41 | | -| |of the figure, and (1, 1) is top | | |
42 | | -| |right of the figure. | | |
43 | | -+----------------+-----------------------------------+-----------------------------+ |
44 | | -|"figure-inches" |The coordinate system of the |``fig.dpi_scale_trans`` | |
45 | | -| |`.Figure` in inches; (0, 0) is | | |
46 | | -| |bottom left of the figure, and | | |
47 | | -| |(width, height) is the top right | | |
48 | | -| |of the figure in inches. | | |
49 | | -+----------------+-----------------------------------+-----------------------------+ |
50 | | -|"xaxis", |Blended coordinate systems, using |``ax.get_xaxis_transform()``,| |
51 | | -|"yaxis" |data coordinates on one direction |``ax.get_yaxis_transform()`` | |
52 | | -| |and axes coordinates on the other. | | |
53 | | -+----------------+-----------------------------------+-----------------------------+ |
54 | | -|"display" |The native coordinate system of the|``None``, or | |
55 | | -| |output ; (0, 0) is the bottom left |``IdentityTransform()`` | |
56 | | -| |of the window, and (width, height) | | |
57 | | -| |is top right of the output in | | |
58 | | -| |"display units". | | |
59 | | -| | | | |
60 | | -| |The exact interpertation of the | | |
61 | | -| |units depends on the back end. For | | |
62 | | -| |example it is pixels for Agg and | | |
63 | | -| |points for svg/pdf. | | |
64 | | -+----------------+-----------------------------------+-----------------------------+ |
| 14 | +table below summarizes some useful coordinate systems, a description of each |
| 15 | +system, and the transformation object for going from each coordinate system to |
| 16 | +the *display* coordinates. In the "Transformation Object" column, ``ax`` is a |
| 17 | +:class:`~matplotlib.axes.Axes` instance, ``fig`` is a |
| 18 | +:class:`~matplotlib.figure.Figure` instance, and ``subfigure`` is a |
| 19 | +:class:`~matplotlib.figure.SubFigure` instance. |
| 20 | +
|
| 21 | +
|
| 22 | ++----------------+-----------------------------------+---------------------------------------------------+ |
| 23 | +|Coordinate |Description |Transformation object | |
| 24 | +|system | |from system to display | |
| 25 | ++================+===================================+===================================================+ |
| 26 | +|"data" |The coordinate system of the data |``ax.transData`` | |
| 27 | +| |in the Axes. | | |
| 28 | ++----------------+-----------------------------------+---------------------------------------------------+ |
| 29 | +|"axes" |The coordinate system of the |``ax.transAxes`` | |
| 30 | +| |`~matplotlib.axes.Axes`; (0, 0) | | |
| 31 | +| |is bottom left of the axes, and | | |
| 32 | +| |(1, 1) is top right of the axes. | | |
| 33 | ++----------------+-----------------------------------+---------------------------------------------------+ |
| 34 | +|"subfigure" |The coordinate system of the |``subfigure.transSubfigure`` | |
| 35 | +| |`.SubFigure`; (0, 0) is bottom left| | |
| 36 | +| |of the subfigure, and (1, 1) is top| | |
| 37 | +| |right of the subfigure. If a | | |
| 38 | +| |figure has no subfigures, this is | | |
| 39 | +| |the same as ``transFigure``. | | |
| 40 | ++----------------+-----------------------------------+---------------------------------------------------+ |
| 41 | +|"figure" |The coordinate system of the |``fig.transFigure`` | |
| 42 | +| |`.Figure`; (0, 0) is bottom left | | |
| 43 | +| |of the figure, and (1, 1) is top | | |
| 44 | +| |right of the figure. | | |
| 45 | ++----------------+-----------------------------------+---------------------------------------------------+ |
| 46 | +|"figure-inches" |The coordinate system of the |``fig.dpi_scale_trans`` | |
| 47 | +| |`.Figure` in inches; (0, 0) is | | |
| 48 | +| |bottom left of the figure, and | | |
| 49 | +| |(width, height) is the top right | | |
| 50 | +| |of the figure in inches. | | |
| 51 | ++----------------+-----------------------------------+---------------------------------------------------+ |
| 52 | +|"xaxis", |Blended coordinate systems, using |``ax.get_xaxis_transform()``, | |
| 53 | +|"yaxis" |data coordinates on one direction |``ax.get_yaxis_transform()`` | |
| 54 | +| |and axes coordinates on the other. | | |
| 55 | ++----------------+-----------------------------------+---------------------------------------------------+ |
| 56 | +|"display" |The native coordinate system of the|`None`, or | |
| 57 | +| |output ; (0, 0) is the bottom left |:class:`~matplotlib.transforms.IdentityTransform()`| |
| 58 | +| |of the window, and (width, height) | | |
| 59 | +| |is top right of the output in | | |
| 60 | +| |"display units". | | |
| 61 | +| | | | |
| 62 | +| |The exact interpertation of the | | |
| 63 | +| |units depends on the back end. For | | |
| 64 | +| |example it is pixels for Agg and | | |
| 65 | +| |points for svg/pdf. | | |
| 66 | ++----------------+-----------------------------------+---------------------------------------------------+ |
65 | 67 |
|
66 | 68 |
|
67 | 69 |
|
|
77 | 79 | transforms. |
78 | 80 |
|
79 | 81 | The transformations also know how to invert themselves (via |
80 | | -`Transform.inverted`) to generate a transform from output coordinate system |
| 82 | +`.Transform.inverted`) to generate a transform from output coordinate system |
81 | 83 | back to the input coordinate system. For example, ``ax.transData`` converts |
82 | 84 | values in data coordinates to display coordinates and |
83 | | -``ax.transData.inversed()`` is a :class:``matplotlib.transforms.Transform` that |
| 85 | +``ax.transData.inversed()`` is a :class:`matplotlib.transforms.Transform` that |
84 | 86 | goes from display coordinates to data coordinates. This is particularly useful |
85 | 87 | when processing events from the user interface, which typically occur in |
86 | 88 | display space, and you want to know where the mouse click or key-press occurred |
|
0 commit comments