@@ -76,137 +76,136 @@ Object interface - Application programmers
76
76
Autoscaling
77
77
~~~~~~~~~~~
78
78
79
- The x and y axis instances no longer have autoscale view. These are
80
- handled by axes.autoscale_view
79
+ The x and y axis instances no longer have autoscale view. These are
80
+ handled by axes.autoscale_view
81
81
82
82
Axes creation
83
83
~~~~~~~~~~~~~
84
84
85
- You should not instantiate your own Axes any more using the OO API.
86
- Rather, create a Figure as before and in place of::
85
+ You should not instantiate your own Axes any more using the OO API.
86
+ Rather, create a Figure as before and in place of::
87
87
88
- f = Figure(figsize=(5,4), dpi=100)
89
- a = Subplot(f, 111)
90
- f.add_axis(a)
88
+ f = Figure(figsize=(5,4), dpi=100)
89
+ a = Subplot(f, 111)
90
+ f.add_axis(a)
91
91
92
- use::
92
+ use::
93
93
94
- f = Figure(figsize=(5,4), dpi=100)
95
- a = f.add_subplot(111)
94
+ f = Figure(figsize=(5,4), dpi=100)
95
+ a = f.add_subplot(111)
96
96
97
- That is, add_axis no longer exists and is replaced by::
97
+ That is, add_axis no longer exists and is replaced by::
98
98
99
- add_axes(rect, axisbg=defaultcolor, frameon=True)
100
- add_subplot(num, axisbg=defaultcolor, frameon=True)
99
+ add_axes(rect, axisbg=defaultcolor, frameon=True)
100
+ add_subplot(num, axisbg=defaultcolor, frameon=True)
101
101
102
102
Artist methods
103
103
~~~~~~~~~~~~~~
104
104
105
- If you define your own Artists, you need to rename the _draw method
106
- to draw
105
+ If you define your own Artists, you need to rename the _draw method
106
+ to draw
107
107
108
108
Bounding boxes
109
109
~~~~~~~~~~~~~~
110
110
111
- matplotlib.transforms.Bound2D is replaced by
112
- matplotlib.transforms.Bbox. If you want to construct a bbox from
113
- left, bottom, width, height (the signature for Bound2D), use
114
- matplotlib.transforms.lbwh_to_bbox, as in
111
+ matplotlib.transforms.Bound2D is replaced by
112
+ matplotlib.transforms.Bbox. If you want to construct a bbox from
113
+ left, bottom, width, height (the signature for Bound2D), use
114
+ matplotlib.transforms.lbwh_to_bbox, as in::
115
115
116
116
bbox = clickBBox = lbwh_to_bbox(left, bottom, width, height)
117
117
118
- The Bbox has a different API than the Bound2D. e.g., if you want to
119
- get the width and height of the bbox
118
+ The Bbox has a different API than the Bound2D. e.g., if you want to
119
+ get the width and height of the bbox
120
120
121
- OLD::
122
- width = fig.bbox.x.interval()
123
- height = fig.bbox.y.interval()
121
+ **OLD **::
124
122
125
- New::
126
- width = fig.bbox.width()
127
- height = fig.bbox.height()
123
+ width = fig.bbox.x.interval()
124
+ height = fig.bbox.y.interval()
128
125
126
+ **NEW **::
129
127
128
+ width = fig.bbox.width()
129
+ height = fig.bbox.height()
130
130
131
131
132
132
Object constructors
133
133
~~~~~~~~~~~~~~~~~~~
134
134
135
- You no longer pass the bbox, dpi, or transforms to the various
136
- Artist constructors. The old way or creating lines and rectangles
137
- was cumbersome because you had to pass so many attributes to the
138
- Line2D and Rectangle classes not related directly to the geometry
139
- and properties of the object. Now default values are added to the
140
- object when you call axes.add_line or axes.add_patch, so they are
141
- hidden from the user.
135
+ You no longer pass the bbox, dpi, or transforms to the various
136
+ Artist constructors. The old way or creating lines and rectangles
137
+ was cumbersome because you had to pass so many attributes to the
138
+ Line2D and Rectangle classes not related directly to the geometry
139
+ and properties of the object. Now default values are added to the
140
+ object when you call axes.add_line or axes.add_patch, so they are
141
+ hidden from the user.
142
142
143
- If you want to define a custom transformation on these objects, call
144
- o.set_transform(trans) where trans is a Transformation instance.
143
+ If you want to define a custom transformation on these objects, call
144
+ o.set_transform(trans) where trans is a Transformation instance.
145
145
146
- In prior versions of you wanted to add a custom line in data coords,
147
- you would have to do
146
+ In prior versions of you wanted to add a custom line in data coords,
147
+ you would have to do::
148
148
149
- l = Line2D(dpi, bbox, x, y,
150
- color = color,
151
- transx = transx,
152
- transy = transy,
153
- )
149
+ l = Line2D(dpi, bbox, x, y,
150
+ color = color,
151
+ transx = transx,
152
+ transy = transy,
153
+ )
154
154
155
- now all you need is
155
+ now all you need is::
156
156
157
- l = Line2D(x, y, color=color)
157
+ l = Line2D(x, y, color=color)
158
158
159
- and the axes will set the transformation for you (unless you have
160
- set your own already, in which case it will eave it unchanged)
159
+ and the axes will set the transformation for you (unless you have
160
+ set your own already, in which case it will eave it unchanged)
161
161
162
162
Transformations
163
163
~~~~~~~~~~~~~~~
164
164
165
- The entire transformation architecture has been rewritten.
166
- Previously the x and y transformations where stored in the xaxis and
167
- yaxis instances. The problem with this approach is it only allows
168
- for separable transforms (where the x and y transformations don't
169
- depend on one another). But for cases like polar, they do. Now
170
- transformations operate on x,y together. There is a new base class
171
- matplotlib.transforms.Transformation and two concrete
172
- implementations, matplotlib.transforms.SeparableTransformation and
173
- matplotlib.transforms.Affine. The SeparableTransformation is
174
- constructed with the bounding box of the input (this determines the
175
- rectangular coordinate system of the input, i.e., the x and y view
176
- limits), the bounding box of the display, and possibly nonlinear
177
- transformations of x and y. The 2 most frequently used
178
- transformations, data coordinates -> display and axes coordinates ->
179
- display are available as ax.transData and ax.transAxes. See
180
- alignment_demo.py which uses axes coords.
181
-
182
- Also, the transformations should be much faster now, for two reasons
183
-
184
- * they are written entirely in extension code
185
-
186
- * because they operate on x and y together, they can do the entire
187
- transformation in one loop. Earlier I did something along the
188
- lines of::
189
-
190
- xt = sx*func(x) + tx
191
- yt = sy*func(y) + ty
192
-
193
- Although this was done in numerix, it still involves 6 length(x)
194
- for-loops (the multiply, add, and function evaluation each for x
195
- and y). Now all of that is done in a single pass.
196
-
197
-
198
- If you are using transformations and bounding boxes to get the
199
- cursor position in data coordinates, the method calls are a little
200
- different now. See the updated examples/coords_demo.py which shows
201
- you how to do this.
202
-
203
- Likewise, if you are using the artist bounding boxes to pick items
204
- on the canvas with the GUI, the bbox methods are somewhat
205
- different. You will need to see the updated
206
- examples/object_picker.py.
207
-
208
- See unit/transforms_unit.py for many examples using the new
209
- transformations.
165
+ The entire transformation architecture has been rewritten.
166
+ Previously the x and y transformations where stored in the xaxis and
167
+ yaxis instances. The problem with this approach is it only allows
168
+ for separable transforms (where the x and y transformations don't
169
+ depend on one another). But for cases like polar, they do. Now
170
+ transformations operate on x,y together. There is a new base class
171
+ matplotlib.transforms.Transformation and two concrete
172
+ implementations, matplotlib.transforms.SeparableTransformation and
173
+ matplotlib.transforms.Affine. The SeparableTransformation is
174
+ constructed with the bounding box of the input (this determines the
175
+ rectangular coordinate system of the input, i.e., the x and y view
176
+ limits), the bounding box of the display, and possibly nonlinear
177
+ transformations of x and y. The 2 most frequently used
178
+ transformations, data coordinates -> display and axes coordinates ->
179
+ display are available as ax.transData and ax.transAxes. See
180
+ alignment_demo.py which uses axes coords.
181
+
182
+ Also, the transformations should be much faster now, for two reasons
183
+
184
+ * they are written entirely in extension code
185
+
186
+ * because they operate on x and y together, they can do the entire
187
+ transformation in one loop. Earlier I did something along the
188
+ lines of::
189
+
190
+ xt = sx*func(x) + tx
191
+ yt = sy*func(y) + ty
192
+
193
+ Although this was done in numerix, it still involves 6 length(x)
194
+ for-loops (the multiply, add, and function evaluation each for x
195
+ and y). Now all of that is done in a single pass.
196
+
197
+ If you are using transformations and bounding boxes to get the
198
+ cursor position in data coordinates, the method calls are a little
199
+ different now. See the updated examples/coords_demo.py which shows
200
+ you how to do this.
201
+
202
+ Likewise, if you are using the artist bounding boxes to pick items
203
+ on the canvas with the GUI, the bbox methods are somewhat
204
+ different. You will need to see the updated
205
+ examples/object_picker.py.
206
+
207
+ See unit/transforms_unit.py for many examples using the new
208
+ transformations.
210
209
211
210
212
211
.. highlight :: none
0 commit comments