@@ -108,24 +108,23 @@ def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None)
108108 marker_trans + transforms .Affine2D ().translate (x , y ),
109109 rgbFace )
110110
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 ):
115114 """
116- Draws a collection of paths, selecting drawing properties from
115+ Draws a collection of paths selecting drawing properties from
117116 the lists *facecolors*, *edgecolors*, *linewidths*,
118117 *linestyles* and *antialiaseds*. *offsets* is a list of
119118 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.
122121
123122 This provides a fallback implementation of
124123 :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
129128 :meth:`_iter_collection_raw_paths` and
130129 :meth:`_iter_collection` are provided to help with (and
131130 standardize) the implementation across backends. It is highly
@@ -137,18 +136,16 @@ def draw_path_collection(self, master_transform, cliprect, clippath,
137136 master_transform , paths , all_transforms ):
138137 path_ids .append ((path , transform ))
139138
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 ,
143141 linewidths , linestyles , antialiaseds , urls ):
144142 path , transform = path_id
145143 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 )
147145
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 ):
152149 """
153150 This provides a fallback implementation of
154151 :meth:`draw_quad_mesh` that generates paths and then calls
@@ -166,11 +163,11 @@ def draw_quad_mesh(self, master_transform, cliprect, clippath,
166163 linewidths = np .array ([0.0 ], np .float_ )
167164
168165 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 ])
172168
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 ):
174171 """
175172 This is a helper method (along with :meth:`_iter_collection`) to make
176173 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):
200197 transform = all_transforms [i % Ntransforms ]
201198 yield path , transform + master_transform
202199
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 ):
206203 """
207204 This is a helper method (along with
208205 :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,
243240 if Noffsets :
244241 toffsets = offsetTrans .transform (offsets )
245242
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 )
252245
253246 if Nfacecolors == 0 :
254247 rgbFace = None
255248
256249 if Nedgecolors == 0 :
257- gc .set_linewidth (0.0 )
250+ gc0 .set_linewidth (0.0 )
258251
259252 xo , yo = 0 , 0
260253 for i in xrange (N ):
@@ -264,20 +257,20 @@ def _iter_collection(self, path_ids, cliprect, clippath, clippath_trans,
264257 if Nfacecolors :
265258 rgbFace = facecolors [i % Nfacecolors ]
266259 if Nedgecolors :
267- gc .set_foreground (edgecolors [i % Nedgecolors ])
260+ gc0 .set_foreground (edgecolors [i % Nedgecolors ])
268261 if Nlinewidths :
269- gc .set_linewidth (linewidths [i % Nlinewidths ])
262+ gc0 .set_linewidth (linewidths [i % Nlinewidths ])
270263 if Nlinestyles :
271- gc .set_dashes (* linestyles [i % Nlinestyles ])
264+ gc0 .set_dashes (* linestyles [i % Nlinestyles ])
272265 if rgbFace is not None and len (rgbFace )== 4 :
273- gc .set_alpha (rgbFace [- 1 ])
266+ gc0 .set_alpha (rgbFace [- 1 ])
274267 rgbFace = rgbFace [:3 ]
275- gc .set_antialiased (antialiaseds [i % Naa ])
268+ gc0 .set_antialiased (antialiaseds [i % Naa ])
276269 if Nurls :
277- gc .set_url (urls [i % Nurls ])
270+ gc0 .set_url (urls [i % Nurls ])
278271
279- yield xo , yo , path_id , gc , rgbFace
280- gc .restore ()
272+ yield xo , yo , path_id , gc0 , rgbFace
273+ gc0 .restore ()
281274
282275 def get_image_magnification (self ):
283276 """
@@ -287,10 +280,13 @@ def get_image_magnification(self):
287280 """
288281 return 1.0
289282
290- def draw_image (self , x , y , im , bbox , clippath = None , clippath_trans = None ):
283+ def draw_image (self , gc , x , y , im ):
291284 """
292285 Draw the image instance into the current axes;
293286
287+ *gc*
288+ a GraphicsContext containing clipping information
289+
294290 *x*
295291 is the distance in pixels from the left hand side of the canvas.
296292
@@ -301,11 +297,6 @@ def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
301297
302298 *im*
303299 the :class:`matplotlib._image.Image` instance
304-
305- *bbox*
306- a :class:`matplotlib.transforms.Bbox` instance for clipping, or
307- None
308-
309300 """
310301 raise NotImplementedError
311302
0 commit comments