@@ -186,14 +186,16 @@ def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None)
186186
187187 def draw_path_collection (self , gc , master_transform , paths , all_transforms ,
188188 offsets , offsetTrans , facecolors , edgecolors ,
189- linewidths , linestyles , antialiaseds , urls ):
189+ linewidths , linestyles , antialiaseds , urls ,
190+ offset_position ):
190191 """
191192 Draws a collection of paths selecting drawing properties from
192193 the lists *facecolors*, *edgecolors*, *linewidths*,
193194 *linestyles* and *antialiaseds*. *offsets* is a list of
194195 offsets to apply to each of the paths. The offsets in
195196 *offsets* are first transformed by *offsetTrans* before being
196- applied.
197+ applied. *offset_position* may be either "screen" or "data"
198+ depending on the space that the offsets are in.
197199
198200 This provides a fallback implementation of
199201 :meth:`draw_path_collection` that makes multiple calls to
@@ -213,8 +215,9 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
213215 path_ids .append ((path , transform ))
214216
215217 for xo , yo , path_id , gc0 , rgbFace in self ._iter_collection (
216- gc , path_ids , offsets , offsetTrans , facecolors , edgecolors ,
217- linewidths , linestyles , antialiaseds , urls ):
218+ gc , master_transform , all_transforms , path_ids , offsets ,
219+ offsetTrans , facecolors , edgecolors , linewidths , linestyles ,
220+ antialiaseds , urls , offset_position ):
218221 path , transform = path_id
219222 transform = transforms .Affine2D (transform .get_matrix ()).translate (xo , yo )
220223 self .draw_path (gc0 , path , transform , rgbFace )
@@ -240,7 +243,7 @@ def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
240243
241244 return self .draw_path_collection (
242245 gc , master_transform , paths , [], offsets , offsetTrans , facecolors ,
243- edgecolors , linewidths , [], [antialiased ], [None ])
246+ edgecolors , linewidths , [], [antialiased ], [None ], 'screen' )
244247
245248 def draw_gouraud_triangle (self , gc , points , colors , transform ):
246249 """
@@ -302,9 +305,10 @@ def _iter_collection_raw_paths(self, master_transform, paths,
302305 transform = all_transforms [i % Ntransforms ]
303306 yield path , transform + master_transform
304307
305- def _iter_collection (self , gc , path_ids , offsets , offsetTrans , facecolors ,
306- edgecolors , linewidths , linestyles , antialiaseds ,
307- urls ):
308+ def _iter_collection (self , gc , master_transform , all_transforms ,
309+ path_ids , offsets , offsetTrans , facecolors ,
310+ edgecolors , linewidths , linestyles ,
311+ antialiaseds , urls , offset_position ):
308312 """
309313 This is a helper method (along with
310314 :meth:`_iter_collection_raw_paths`) to make it easier to write
@@ -330,6 +334,7 @@ def _iter_collection(self, gc, path_ids, offsets, offsetTrans, facecolors,
330334 *path_ids*; *gc* is a graphics context and *rgbFace* is a color to
331335 use for filling the path.
332336 """
337+ Ntransforms = len (all_transforms )
333338 Npaths = len (path_ids )
334339 Noffsets = len (offsets )
335340 N = max (Npaths , Noffsets )
@@ -359,6 +364,15 @@ def _iter_collection(self, gc, path_ids, offsets, offsetTrans, facecolors,
359364 path_id = path_ids [i % Npaths ]
360365 if Noffsets :
361366 xo , yo = toffsets [i % Noffsets ]
367+ if offset_position == 'data' :
368+ if Ntransforms :
369+ transform = all_transforms [i % Ntransforms ] + master_transform
370+ else :
371+ transform = master_transform
372+ xo , yo = transform .transform_point ((xo , yo ))
373+ xp , yp = transform .transform_point ((0 , 0 ))
374+ xo = - (xp - xo )
375+ yo = - (yp - yo )
362376 if Nfacecolors :
363377 rgbFace = facecolors [i % Nfacecolors ]
364378 if Nedgecolors :
0 commit comments