|
24 | 24 | Coordinate Transformation Object Description |
25 | 25 | ========== ===================== ==================================================================================== |
26 | 26 | `data` ``ax.transData`` The userland data coordinate system, controlled by the xlim and ylim |
27 | | -`axes` ``ax.transAxes`` The coordinate system of the :class:`~matplotlib.axes.Axes`; (0,0) is |
28 | | - bottom left of the axes, and (1,1) is top right of the axes. |
29 | | -`figure` ``fig.transFigure`` The coordinate system of the :class:`~matplotlib.figure.Figure`; (0,0) |
30 | | - is bottom left of the figure, and (1,1) is top right of the figure. |
31 | | -`display` `None` This is the pixel coordinate system of the display; (0,0) is the bottom |
| 27 | +`axes` ``ax.transAxes`` The coordinate system of the :class:`~matplotlib.axes.Axes`; (0, 0) is |
| 28 | + bottom left of the axes, and (1, 1) is top right of the axes. |
| 29 | +`figure` ``fig.transFigure`` The coordinate system of the :class:`~matplotlib.figure.Figure`; (0, 0) |
| 30 | + is bottom left of the figure, and (1, 1) is top right of the figure. |
| 31 | +`display` `None` This is the pixel coordinate system of the display; (0, 0) is the bottom |
32 | 32 | left of the display, and (width, height) is the top right of the display in pixels. |
33 | 33 | Alternatively, the identity transform |
34 | 34 | (:class:`matplotlib.transforms.IdentityTransform()`) may be used instead of None. |
|
87 | 87 | # In [15]: ax.transData.transform((5, 0)) |
88 | 88 | # Out[15]: array([ 335.175, 247. ]) |
89 | 89 | # |
90 | | -# In [16]: ax.transData.transform([(5, 0), (1,2)]) |
| 90 | +# In [16]: ax.transData.transform([(5, 0), (1, 2)]) |
91 | 91 | # Out[16]: |
92 | 92 | # array([[ 335.175, 247. ], |
93 | 93 | # [ 132.435, 642.2 ]]) |
|
170 | 170 | # In [54]: ax.transData.transform((5, 0)) |
171 | 171 | # Out[54]: array([ 335.175, 247. ]) |
172 | 172 | # |
173 | | -# In [55]: ax.set_ylim(-1,2) |
| 173 | +# In [55]: ax.set_ylim(-1, 2) |
174 | 174 | # Out[55]: (-1, 2) |
175 | 175 | # |
176 | 176 | # In [56]: ax.transData.transform((5, 0)) |
177 | 177 | # Out[56]: array([ 335.175 , 181.13333333]) |
178 | 178 | # |
179 | | -# In [57]: ax.set_xlim(10,20) |
| 179 | +# In [57]: ax.set_xlim(10, 20) |
180 | 180 | # Out[57]: (10, 20) |
181 | 181 | # |
182 | 182 | # In [58]: ax.transData.transform((5, 0)) |
|
189 | 189 | # ================ |
190 | 190 | # |
191 | 191 | # After the `data` coordinate system, `axes` is probably the second most |
192 | | -# useful coordinate system. Here the point (0,0) is the bottom left of |
| 192 | +# useful coordinate system. Here the point (0, 0) is the bottom left of |
193 | 193 | # your axes or subplot, (0.5, 0.5) is the center, and (1.0, 1.0) is the |
194 | 194 | # top right. You can also refer to points outside the range, so (-0.1, |
195 | 195 | # 1.1) is to the left and above your axes. This coordinate system is |
|
272 | 272 | # highlight the 1..2 stddev region with a span. |
273 | 273 | # We want x to be in data coordinates and y to |
274 | 274 | # span from 0..1 in axes coords |
275 | | -rect = patches.Rectangle((1,0), width=1, height=1, |
| 275 | +rect = patches.Rectangle((1, 0), width=1, height=1, |
276 | 276 | transform=trans, color='yellow', |
277 | 277 | alpha=0.5) |
278 | 278 |
|
|
389 | 389 | # self.transData = self.transScale + (self.transLimits + self.transAxes) |
390 | 390 | # |
391 | 391 | # We've been introduced to the ``transAxes`` instance above in |
392 | | -# :ref:`axes-coords`, which maps the (0,0), (1,1) corners of the |
| 392 | +# :ref:`axes-coords`, which maps the (0, 0), (1, 1) corners of the |
393 | 393 | # axes or subplot bounding box to `display` space, so let's look at |
394 | 394 | # these other two pieces. |
395 | 395 | # |
|
405 | 405 | # In [81]: ax.set_xlim(0, 10) |
406 | 406 | # Out[81]: (0, 10) |
407 | 407 | # |
408 | | -# In [82]: ax.set_ylim(-1,1) |
| 408 | +# In [82]: ax.set_ylim(-1, 1) |
409 | 409 | # Out[82]: (-1, 1) |
410 | 410 | # |
411 | | -# In [84]: ax.transLimits.transform((0,-1)) |
| 411 | +# In [84]: ax.transLimits.transform((0, -1)) |
412 | 412 | # Out[84]: array([ 0., 0.]) |
413 | 413 | # |
414 | | -# In [85]: ax.transLimits.transform((10,-1)) |
| 414 | +# In [85]: ax.transLimits.transform((10, -1)) |
415 | 415 | # Out[85]: array([ 1., 0.]) |
416 | 416 | # |
417 | | -# In [86]: ax.transLimits.transform((10,1)) |
| 417 | +# In [86]: ax.transLimits.transform((10, 1)) |
418 | 418 | # Out[86]: array([ 1., 1.]) |
419 | 419 | # |
420 | | -# In [87]: ax.transLimits.transform((5,0)) |
| 420 | +# In [87]: ax.transLimits.transform((5, 0)) |
421 | 421 | # Out[87]: array([ 0.5, 0.5]) |
422 | 422 | # |
423 | 423 | # and we can use this same inverted transformation to go from the unit |
|
0 commit comments