Skip to content

Commit e3410fe

Browse files
committed
DOC: Refresh transform tree example
This sample image appears to have been created with Graphviz, but I cannot find any source, making it difficult to update. Since we already require Graphviz for the inheritance diagrams, we can use it to generate this image. As we output Graphviz as SVG now, we can add a bit of interactivity here to link the classes that are mentioned here, just like the inheritance diagrams. Also, annotate the transforms with the class attributes that they represent, fill in some of the lower transforms that are set after an `Axes` is parented, and style a bit more like the inheritance diagrams.
1 parent 9489b93 commit e3410fe

File tree

4 files changed

+147
-6
lines changed

4 files changed

+147
-6
lines changed

doc/_static/transforms.png

-47.5 KB
Binary file not shown.

doc/api/transforms.dot

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
digraph {
2+
splines="polyline";
3+
4+
node [
5+
fontname="DejaVu Sans, Vera Sans, Liberation Sans, Arial, Helvetica, sans",
6+
shape=box,
7+
];
8+
edge [
9+
arrowsize=0.5,
10+
fontname="DejaVu Sans, Vera Sans, Liberation Sans, Arial, Helvetica, sans",
11+
];
12+
13+
// Axes properties.
14+
Axes__bbox [
15+
label=<TransformedBbox<BR/><FONT POINT-SIZE="10">Axes.bbox</FONT>>,
16+
target="_top",
17+
tooltip="TransformedBbox",
18+
URL="transformations.html#matplotlib.transforms.TransformedBbox",
19+
];
20+
Axes__transAxes [
21+
label=<BboxTransformTo<BR/><FONT POINT-SIZE="10">Axes.transAxes</FONT>>
22+
target="_top",
23+
tooltip="BboxTransformTo",
24+
URL="transformations.html#matplotlib.transforms.BboxTransformTo",
25+
];
26+
Axes__transData [
27+
label=<CompositeGenericTransform<BR/><FONT
28+
POINT-SIZE="10">Axes.transData</FONT>>
29+
target="_top",
30+
tooltip="CompositeGenericTransform",
31+
URL="transformations.html#matplotlib.transforms.CompositeGenericTransform",
32+
];
33+
Axes__transLimits [
34+
label=<BboxTransformFrom<BR/><FONT POINT-SIZE="10">Axes.transLimits</FONT>>
35+
target="_top",
36+
tooltip="BboxTransformFrom",
37+
URL="transformations.html#matplotlib.transforms.BboxTransformFrom",
38+
];
39+
Axes__transScale [
40+
label=<TransformWrapper<BR/><FONT POINT-SIZE="10">Axes.transScale</FONT>>
41+
target="_top",
42+
tooltip="TransformWrapper",
43+
URL="transformations.html#matplotlib.transforms.TransformWrapper",
44+
];
45+
Axes__position [
46+
label=<Bbox<BR/><FONT POINT-SIZE="10">Axes.get_position()</FONT>>
47+
target="_top",
48+
tooltip="Bbox",
49+
URL="transformations.html#matplotlib.transforms.Bbox",
50+
];
51+
Axes__viewLim [
52+
label = <Bbox<BR/><FONT POINT-SIZE="10">Axes._viewLim</FONT>>
53+
target="_top",
54+
tooltip="Bbox",
55+
URL="transformations.html#matplotlib.transforms.Bbox",
56+
];
57+
58+
// Axis properties.
59+
XAxis_transform [
60+
label=<IdentityTransform<BR/><FONT
61+
POINT-SIZE="10">Axes.xaxis.get_transform()</FONT>>
62+
target="_top",
63+
tooltip="IdentityTransform",
64+
URL="transformations.html#matplotlib.transforms.IdentityTransform",
65+
];
66+
YAxis_transform [
67+
label=<IdentityTransform<BR/><FONT
68+
POINT-SIZE="10">Axes.yaxis.get_transform()</FONT>>
69+
target="_top",
70+
tooltip="IdentityTransform",
71+
URL="transformations.html#matplotlib.transforms.IdentityTransform",
72+
];
73+
74+
// Figure properties.
75+
Figure__transFigure [
76+
label=<BboxTransformTo<BR/><FONT POINT-SIZE="10">Figure.transFigure</FONT>>
77+
target="_top",
78+
tooltip="BboxTransformTo",
79+
URL="transformations.html#matplotlib.transforms.BboxTransformTo",
80+
];
81+
Figure__bbox [
82+
label=<TransformedBbox<BR/><FONT POINT-SIZE="10">Figure.bbox</FONT>>
83+
target="_top",
84+
tooltip="TransformedBbox",
85+
URL="transformations.html#matplotlib.transforms.TransformedBbox",
86+
];
87+
Figure__bbox_inches [
88+
label=<Bbox<BR/><FONT POINT-SIZE="10">Figure.bbox_inches</FONT>>
89+
target="_top",
90+
tooltip="Bbox",
91+
URL="transformations.html#matplotlib.transforms.Bbox",
92+
];
93+
Figure__dpi_scale_trans [
94+
label=<Affine2D<BR/><FONT POINT-SIZE="10">Figure.dpi_scale_trans</FONT>>
95+
target="_top",
96+
tooltip="Affine2D",
97+
URL="transformations.html#matplotlib.transforms.Affine2D",
98+
];
99+
100+
// Internal unnamed transform children.
101+
Axes__transDataB [
102+
label="CompositeGenericTransform",
103+
target="_top",
104+
tooltip="CompositeGenericTransform",
105+
URL="transformations.html#matplotlib.transforms.CompositeGenericTransform",
106+
];
107+
Axes__transLimitsBbox [
108+
label="TransformedBbox",
109+
target="_top",
110+
tooltip="TransformedBbox",
111+
URL="transformations.html#matplotlib.transforms.TransformedBbox",
112+
];
113+
Axes__transScaleBlend [
114+
label="BlendedAffine2D",
115+
target="_top",
116+
tooltip="BlendedAffine2D",
117+
URL="transformations.html#matplotlib.transforms.BlendedAffine2D",
118+
];
119+
120+
// The actual Axes__transform tree follows:
121+
Axes__transData -> Axes__transScale [label="a", labelangle=90];
122+
Axes__transData -> Axes__transDataB [label="b"];
123+
Axes__transDataB -> Axes__transLimits [label="a"];
124+
Axes__transDataB -> Axes__transAxes [label="b"];
125+
126+
Axes__transScale -> Axes__transScaleBlend [label="child"];
127+
Axes__transScaleBlend -> XAxis_transform [label="x_transform"];
128+
Axes__transScaleBlend -> YAxis_transform [label="y_transform"];
129+
130+
Axes__transLimits -> Axes__transLimitsBbox [label="boxin"];
131+
Axes__transLimitsBbox -> Axes__viewLim [label="bbox"];
132+
Axes__transLimitsBbox -> Axes__transScale [label="transform"];
133+
134+
Axes__transAxes -> Axes__bbox [label="boxout"];
135+
Axes__bbox -> Axes__position [label="bbox"];
136+
Axes__bbox -> Figure__transFigure [label="transform"];
137+
138+
Figure__transFigure -> Figure__bbox [label="boxout"];
139+
Figure__bbox -> Figure__bbox_inches [label="bbox"];
140+
Figure__bbox -> Figure__dpi_scale_trans [label="transform"];
141+
}

doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ def _parse_skip_subdirs_file():
108108
extensions = [
109109
'sphinx.ext.autodoc',
110110
'sphinx.ext.autosummary',
111+
'sphinx.ext.graphviz',
111112
'sphinx.ext.inheritance_diagram',
112113
'sphinx.ext.intersphinx',
113114
'sphinx.ext.ifconfig',

lib/matplotlib/transforms.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""
2-
Matplotlib includes a framework for arbitrary geometric
3-
transformations that is used determine the final position of all
4-
elements drawn on the canvas.
2+
Matplotlib includes a framework for arbitrary geometric transformations that is used to
3+
determine the final position of all elements drawn on the canvas.
54
65
Transforms are composed into trees of `TransformNode` objects
76
whose actual value depends on their children. When the contents of
@@ -11,10 +10,10 @@
1110
unnecessary recomputations of transforms, and contributes to better
1211
interactive performance.
1312
14-
For example, here is a graph of the transform tree used to plot data
15-
to the graph:
13+
For example, here is a graph of the transform tree used to plot data to the figure:
1614
17-
.. image:: ../_static/transforms.png
15+
.. graphviz:: /api/transforms.dot
16+
:alt: Diagram of transform tree from data to figure coordinates.
1817
1918
The framework can be used for both affine and non-affine
2019
transformations. However, for speed, we want to use the backend

0 commit comments

Comments
 (0)