@@ -26,14 +26,11 @@ def __init__(self, offset=(0., 0.)):
2626 The offset to apply to the path, measured in points.
2727 """
2828 self ._offset = offset
29- self ._offset_trans = mtransforms .Affine2D ()
3029
31- def _offset_transform (self , renderer , transform ):
30+ def _offset_transform (self , renderer ):
3231 """Apply the offset to the given transform."""
33- offset_x = renderer .points_to_pixels (self ._offset [0 ])
34- offset_y = renderer .points_to_pixels (self ._offset [1 ])
35- return transform + self ._offset_trans .clear ().translate (offset_x ,
36- offset_y )
32+ return mtransforms .Affine2D ().translate (
33+ * map (renderer .points_to_pixels , self ._offset ))
3734
3835 def _update_gc (self , gc , new_gc_dict ):
3936 """
@@ -180,14 +177,11 @@ def draw_path(self, renderer, gc, tpath, affine, rgbFace):
180177 """
181178 Draw the path with updated gc.
182179 """
183- # Do not modify the input! Use copy instead.
184-
185- gc0 = renderer .new_gc ()
180+ gc0 = renderer .new_gc () # Don't modify gc, but a copy!
186181 gc0 .copy_properties (gc )
187-
188182 gc0 = self ._update_gc (gc0 , self ._gc )
189- trans = self . _offset_transform ( renderer , affine )
190- renderer . draw_path ( gc0 , tpath , trans , rgbFace )
183+ renderer . draw_path (
184+ gc0 , tpath , affine + self . _offset_transform ( renderer ) , rgbFace )
191185 gc0 .restore ()
192186
193187
@@ -246,11 +240,8 @@ def draw_path(self, renderer, gc, tpath, affine, rgbFace):
246240 """
247241 Overrides the standard draw_path to add the shadow offset and
248242 necessary color changes for the shadow.
249-
250243 """
251- # IMPORTANT: Do not modify the input - we copy everything instead.
252- affine0 = self ._offset_transform (renderer , affine )
253- gc0 = renderer .new_gc ()
244+ gc0 = renderer .new_gc () # Don't modify gc, but a copy!
254245 gc0 .copy_properties (gc )
255246
256247 if self ._shadow_rgbFace is None :
@@ -265,7 +256,9 @@ def draw_path(self, renderer, gc, tpath, affine, rgbFace):
265256 gc0 .set_linewidth (0 )
266257
267258 gc0 = self ._update_gc (gc0 , self ._gc )
268- renderer .draw_path (gc0 , tpath , affine0 , shadow_rgbFace )
259+ renderer .draw_path (
260+ gc0 , tpath , affine + self ._offset_transform (renderer ),
261+ shadow_rgbFace )
269262 gc0 .restore ()
270263
271264
@@ -317,11 +310,8 @@ def draw_path(self, renderer, gc, tpath, affine, rgbFace):
317310 """
318311 Overrides the standard draw_path to add the shadow offset and
319312 necessary color changes for the shadow.
320-
321313 """
322- # IMPORTANT: Do not modify the input - we copy everything instead.
323- affine0 = self ._offset_transform (renderer , affine )
324- gc0 = renderer .new_gc ()
314+ gc0 = renderer .new_gc () # Don't modify gc, but a copy!
325315 gc0 .copy_properties (gc )
326316
327317 if self ._shadow_color is None :
@@ -331,13 +321,12 @@ def draw_path(self, renderer, gc, tpath, affine, rgbFace):
331321 else :
332322 shadow_rgbFace = self ._shadow_color
333323
334- fill_color = None
335-
336324 gc0 .set_foreground (shadow_rgbFace )
337325 gc0 .set_alpha (self ._alpha )
338326
339327 gc0 = self ._update_gc (gc0 , self ._gc )
340- renderer .draw_path (gc0 , tpath , affine0 , fill_color )
328+ renderer .draw_path (
329+ gc0 , tpath , affine + self ._offset_transform (renderer ))
341330 gc0 .restore ()
342331
343332
@@ -363,9 +352,8 @@ def __init__(self, offset=(0, 0), **kwargs):
363352 self .patch = mpatches .PathPatch ([], ** kwargs )
364353
365354 def draw_path (self , renderer , gc , tpath , affine , rgbFace ):
366- affine = self ._offset_transform (renderer , affine )
367355 self .patch ._path = tpath
368- self .patch .set_transform (affine )
356+ self .patch .set_transform (affine + self . _offset_transform ( renderer ) )
369357 self .patch .set_clip_box (gc .get_clip_rectangle ())
370358 clip_path = gc .get_clip_path ()
371359 if clip_path :
0 commit comments