fig
subfigure
Coordinate
system | Description | Transformation object
from system to display |
|---|
data | The coordinate system of the data
in the Axes. | ax.transData
|
axes | The coordinate system of the
Axes; (0, 0)
is bottom left of the Axes, and
(1, 1) is top right of the Axes. | ax.transAxes
|
subfigure | The coordinate system of the
SubFigure; (0, 0) is bottom left
of the subfigure, and (1, 1) is top
right of the subfigure. If a
figure has no subfigures, this is
the same as transFigure. | subfigure.transSubfigure
|
figure | The coordinate system of the
Figure; (0, 0) is bottom left
of the figure, and (1, 1) is top
right of the figure. | fig.transFigure
|
figure-inches | The coordinate system of the
Figure in inches; (0, 0) is
bottom left of the figure, and
(width, height) is the top right
of the figure in inches. | fig.dpi_scale_trans
|
xaxis,
yaxis | Blended coordinate systems, using
data coordinates on one direction
and axes coordinates on the other. | ax.get_xaxis_transform(),
ax.get_yaxis_transform()
|
display | The native coordinate system of the
output ; (0, 0) is the bottom left
of the window, and (width, height)
is top right of the output in
"display units".
"Display units" depends on the
backend. For example, Agg uses
pixels, and SVG/PDF use points.
| None, or
IdentityTransform()
|
The Transform objects are naive to the source and
destination coordinate systems, however the objects referred to in the table
above are constructed to take inputs in their coordinate system, and transform
the input to the display coordinate system. That is why the display
coordinate system has None for the "Transformation Object" column -- it
already is in display coordinates. The naming and destination conventions
are an aid to keeping track of the available "standard" coordinate systems and
transforms.
The transformations also know how to invert themselves (via
Transform.inverted) to generate a transform from output coordinate system
back to the input coordinate system. For example, ax.transData converts
values in data coordinates to display coordinates and
ax.transData.inverted() is a matplotlib.transforms.Transform that
goes from display coordinates to data coordinates. This is particularly useful
when processing events from the user interface, which typically occur in
display space, and you want to know where the mouse click or key-press occurred
in your data coordinate system.
Note that specifying the position of Artists in display coordinates may
change their relative location if the dpi or size of the figure changes.
This can cause confusion when printing or changing screen resolution, because
the object can change location and size. Therefore, it is most common for
artists placed in an Axes or figure to have their transform set to something
other than the IdentityTransform(); the default when an artist
is added to an Axes using add_artist is for the transform to be
ax.transData so that you can work and think in data coordinates and let
Matplotlib take care of the transformation to display.
.
transData
.
transform
([(
5
,
0
),
(
1
,
2
)])
Out[16]:
array([[ 335.175, 247. ],
[ 132.435, 642.2 ]])
*
(
2
*
*
)
,
=
()
(
,
)
(
0
,
10
)
(
-
1
,
1
)
,
=
5
,
0
,
=
((
,
))
=
dict
(
boxstyle
=
"round"
,
fc
=
"0.8"
)
=
dict
(
arrowstyle
=
"->"
,
connectionstyle
=
"angle,angleA=0,angleB=90,rad=10"
)
=
72
(
f
'data = (
{
:
.1f
}
,
{
:
.1f
}
)'
,
(
,
),
xytext
=
(
-
2
*
,
),
textcoords
=
'offset points'
,
=
,
=
)
=
(
f
'display = (
{
:
.1f
}
,
{
:
.1f
}
)'
,
(
,
),
xytext
=
(
0.5
*
,
-
),
xycoords
=
'figure pixels'
,
textcoords
=
'offset points'
,
=
,
=
)
()
ax
.
transData
.
transform
((
5
,
0
))
Out[56]:
array([ 335.175 , 181.13333333])
(
10
,
20
)
Out[57]:
(10, 20)
((
5
,
0
))
Out[58]:
array([-171.675 , 181.13333333])
rand
(
2
,
1000
)
(
,
,
'go'
,
alpha
=
0.2
)
=
((
0.5
,
0.5
),
0.25
,
transform
=
,
facecolor
=
'blue'
,
alpha
=
0.75
)
(
)
()
(
1000
)
(
,
30
)
(
r
'$\sigma=1 \/ \dots \/ \sigma=2$'
,
fontsize
=
16
)
=
(
,
)
=
((
1
,
0
),
width
=
1
,
height
=
1
,
transform
=
,
color
=
'yellow'
,
alpha
=
0.5
)
(
)
()
np
.
random
.
rand
(
2
,
1000
)
(
,
*
10.
,
'go'
,
alpha
=
0.2
)
=
((
2.5
,
2
),
1.0
,
transform
=
,
facecolor
=
'blue'
,
alpha
=
0.75
)
(
)
()
(
,
,
"o"
)
(
0
,
1
)
=
(
+
(
[
0
],
[
0
],
))
=
((
0
,
0
),
150
/
72
,
130
/
72
,
angle
=
40
,
fill
=
None
,
transform
=
)
(
)
()
=
(
2
*
*
)
,
=
(
,
,
lw
=
3
,
color
=
'blue'
)
,
=
2
/
72.
,
-
2
/
72.
=
(
,
,
)
=
+
(
,
,
lw
=
3
,
color
=
'gray'
,
transform
=
,
zorder
=
0.5
*
())
(
'creating a shadow effect with an offset transform'
)
()
fig
,
,
,
units
=
'inches'
)
1
)
Out[82]:
(-1, 1)
.
transLimits
.
transform
((
0
,
-
1
))
Out[84]:
array([ 0., 0.])
.
transLimits
.
transform
((
10
,
-
1
))
Out[85]:
array([ 1., 0.])
.
transLimits
.
transform
((
10
,
1
))
Out[86]:
array([ 1., 1.])
.
transLimits
.
transform
((
5
,
0
))
Out[87]:
array([ 0.5, 0.5])
ax.set_xscale('log')
Download zipped: transforms_tutorial.zip