@@ -108,24 +108,23 @@ def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None)
108
108
marker_trans + transforms .Affine2D ().translate (x , y ),
109
109
rgbFace )
110
110
111
- def draw_path_collection (self , master_transform , cliprect , clippath ,
112
- clippath_trans , paths , all_transforms , offsets ,
113
- offsetTrans , facecolors , edgecolors , linewidths ,
114
- linestyles , antialiaseds , urls ):
111
+ def draw_path_collection (self , gc , master_transform , paths , all_transforms ,
112
+ offsets , offsetTrans , facecolors , edgecolors ,
113
+ linewidths , linestyles , antialiaseds , urls ):
115
114
"""
116
- Draws a collection of paths, selecting drawing properties from
115
+ Draws a collection of paths selecting drawing properties from
117
116
the lists *facecolors*, *edgecolors*, *linewidths*,
118
117
*linestyles* and *antialiaseds*. *offsets* is a list of
119
118
offsets to apply to each of the paths. The offsets in
120
- *offsets* are first transformed by *offsetTrans* before
121
- being applied.
119
+ *offsets* are first transformed by *offsetTrans* before being
120
+ applied.
122
121
123
122
This provides a fallback implementation of
124
123
:meth:`draw_path_collection` that makes multiple calls to
125
- draw_path. Some backends may want to override this in order
126
- to render each set of path data only once, and then reference
127
- that path multiple times with the different offsets, colors ,
128
- styles etc. The generator methods
124
+ :meth:` draw_path` . Some backends may want to override this in
125
+ order to render each set of path data only once, and then
126
+ reference that path multiple times with the different offsets,
127
+ colors, styles etc. The generator methods
129
128
:meth:`_iter_collection_raw_paths` and
130
129
:meth:`_iter_collection` are provided to help with (and
131
130
standardize) the implementation across backends. It is highly
@@ -137,18 +136,16 @@ def draw_path_collection(self, master_transform, cliprect, clippath,
137
136
master_transform , paths , all_transforms ):
138
137
path_ids .append ((path , transform ))
139
138
140
- for xo , yo , path_id , gc , rgbFace in self ._iter_collection (
141
- path_ids , cliprect , clippath , clippath_trans ,
142
- offsets , offsetTrans , facecolors , edgecolors ,
139
+ for xo , yo , path_id , gc0 , rgbFace in self ._iter_collection (
140
+ gc , path_ids , offsets , offsetTrans , facecolors , edgecolors ,
143
141
linewidths , linestyles , antialiaseds , urls ):
144
142
path , transform = path_id
145
143
transform = transforms .Affine2D (transform .get_matrix ()).translate (xo , yo )
146
- self .draw_path (gc , path , transform , rgbFace )
144
+ self .draw_path (gc0 , path , transform , rgbFace )
147
145
148
- def draw_quad_mesh (self , master_transform , cliprect , clippath ,
149
- clippath_trans , meshWidth , meshHeight , coordinates ,
150
- offsets , offsetTrans , facecolors , antialiased ,
151
- showedges ):
146
+ def draw_quad_mesh (self , gc , master_transform , meshWidth , meshHeight ,
147
+ coordinates , offsets , offsetTrans , facecolors ,
148
+ antialiased , showedges ):
152
149
"""
153
150
This provides a fallback implementation of
154
151
:meth:`draw_quad_mesh` that generates paths and then calls
@@ -166,11 +163,11 @@ def draw_quad_mesh(self, master_transform, cliprect, clippath,
166
163
linewidths = np .array ([0.0 ], np .float_ )
167
164
168
165
return self .draw_path_collection (
169
- master_transform , cliprect , clippath , clippath_trans ,
170
- paths , [], offsets , offsetTrans , facecolors , edgecolors ,
171
- linewidths , [], [antialiased ], [None ])
166
+ gc , master_transform , paths , [], offsets , offsetTrans , facecolors ,
167
+ edgecolors , linewidths , [], [antialiased ], [None ])
172
168
173
- def _iter_collection_raw_paths (self , master_transform , paths , all_transforms ):
169
+ def _iter_collection_raw_paths (self , master_transform , paths ,
170
+ all_transforms ):
174
171
"""
175
172
This is a helper method (along with :meth:`_iter_collection`) to make
176
173
it easier to write a space-efficent :meth:`draw_path_collection`
@@ -200,9 +197,9 @@ def _iter_collection_raw_paths(self, master_transform, paths, all_transforms):
200
197
transform = all_transforms [i % Ntransforms ]
201
198
yield path , transform + master_transform
202
199
203
- def _iter_collection (self , path_ids , cliprect , clippath , clippath_trans ,
204
- offsets , offsetTrans , facecolors , edgecolors ,
205
- linewidths , linestyles , antialiaseds , urls ):
200
+ def _iter_collection (self , gc , path_ids , offsets , offsetTrans , facecolors ,
201
+ edgecolors , linewidths , linestyles , antialiaseds ,
202
+ urls ):
206
203
"""
207
204
This is a helper method (along with
208
205
:meth:`_iter_collection_raw_paths`) to make it easier to write
@@ -243,18 +240,14 @@ def _iter_collection(self, path_ids, cliprect, clippath, clippath_trans,
243
240
if Noffsets :
244
241
toffsets = offsetTrans .transform (offsets )
245
242
246
- gc = self .new_gc ()
247
-
248
- gc .set_clip_rectangle (cliprect )
249
- if clippath is not None :
250
- clippath = transforms .TransformedPath (clippath , clippath_trans )
251
- gc .set_clip_path (clippath )
243
+ gc0 = self .new_gc ()
244
+ gc0 .copy_properties (gc )
252
245
253
246
if Nfacecolors == 0 :
254
247
rgbFace = None
255
248
256
249
if Nedgecolors == 0 :
257
- gc .set_linewidth (0.0 )
250
+ gc0 .set_linewidth (0.0 )
258
251
259
252
xo , yo = 0 , 0
260
253
for i in xrange (N ):
@@ -264,20 +257,20 @@ def _iter_collection(self, path_ids, cliprect, clippath, clippath_trans,
264
257
if Nfacecolors :
265
258
rgbFace = facecolors [i % Nfacecolors ]
266
259
if Nedgecolors :
267
- gc .set_foreground (edgecolors [i % Nedgecolors ])
260
+ gc0 .set_foreground (edgecolors [i % Nedgecolors ])
268
261
if Nlinewidths :
269
- gc .set_linewidth (linewidths [i % Nlinewidths ])
262
+ gc0 .set_linewidth (linewidths [i % Nlinewidths ])
270
263
if Nlinestyles :
271
- gc .set_dashes (* linestyles [i % Nlinestyles ])
264
+ gc0 .set_dashes (* linestyles [i % Nlinestyles ])
272
265
if rgbFace is not None and len (rgbFace )== 4 :
273
- gc .set_alpha (rgbFace [- 1 ])
266
+ gc0 .set_alpha (rgbFace [- 1 ])
274
267
rgbFace = rgbFace [:3 ]
275
- gc .set_antialiased (antialiaseds [i % Naa ])
268
+ gc0 .set_antialiased (antialiaseds [i % Naa ])
276
269
if Nurls :
277
- gc .set_url (urls [i % Nurls ])
270
+ gc0 .set_url (urls [i % Nurls ])
278
271
279
- yield xo , yo , path_id , gc , rgbFace
280
- gc .restore ()
272
+ yield xo , yo , path_id , gc0 , rgbFace
273
+ gc0 .restore ()
281
274
282
275
def get_image_magnification (self ):
283
276
"""
@@ -287,10 +280,13 @@ def get_image_magnification(self):
287
280
"""
288
281
return 1.0
289
282
290
- def draw_image (self , x , y , im , bbox , clippath = None , clippath_trans = None ):
283
+ def draw_image (self , gc , x , y , im ):
291
284
"""
292
285
Draw the image instance into the current axes;
293
286
287
+ *gc*
288
+ a GraphicsContext containing clipping information
289
+
294
290
*x*
295
291
is the distance in pixels from the left hand side of the canvas.
296
292
@@ -301,11 +297,6 @@ def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
301
297
302
298
*im*
303
299
the :class:`matplotlib._image.Image` instance
304
-
305
- *bbox*
306
- a :class:`matplotlib.transforms.Bbox` instance for clipping, or
307
- None
308
-
309
300
"""
310
301
raise NotImplementedError
311
302
0 commit comments