@@ -481,13 +481,14 @@ def get_hatch(self):
481
481
return self ._hatch
482
482
483
483
@contextlib .contextmanager
484
- def _prepare_path_drawer (self , renderer ):
484
+ def _bind_draw_path_function (self , renderer ):
485
485
"""
486
486
``draw()`` helper factored out for sharing with `FancyArrowPatch`.
487
487
488
- Yields a callable that can be called as a bound ``draw_path`` method
489
- except that the first argument (the ``GraphicsContext``) has already
490
- been suitably filled in.
488
+ Yields a callable ``dp`` such that calling ``dp(*args, **kwargs)`` is
489
+ equivalent to calling ``renderer1.draw_path(gc, *args, **kwargs)``
490
+ where ``renderer1`` and ``gc`` have been suitably set from ``renderer``
491
+ and the artist's properties.
491
492
"""
492
493
493
494
renderer .open_group ('patch' , self .get_gid ())
@@ -499,7 +500,7 @@ def _prepare_path_drawer(self, renderer):
499
500
if self ._edgecolor [3 ] == 0 :
500
501
lw = 0
501
502
gc .set_linewidth (lw )
502
- gc .set_dashes (0 , self ._dashes )
503
+ gc .set_dashes (self . _dashoffset , self ._dashes )
503
504
gc .set_capstyle (self ._capstyle )
504
505
gc .set_joinstyle (self ._joinstyle )
505
506
@@ -530,7 +531,7 @@ def _prepare_path_drawer(self, renderer):
530
531
from matplotlib .patheffects import PathEffectRenderer
531
532
renderer = PathEffectRenderer (self .get_path_effects (), renderer )
532
533
533
- # In `with _prepare_path_drawer (renderer) as draw_path: draw_path( ...) `
534
+ # In `with _bind_draw_path_function (renderer) as draw_path: ...`
534
535
# (in the implementations of `draw()` below), calls to `draw_path(...)`
535
536
# will occur as if they took place here with `gc` inserted as
536
537
# additional first argument.
@@ -546,7 +547,10 @@ def draw(self, renderer):
546
547
if not self .get_visible ():
547
548
return
548
549
549
- with self ._prepare_path_drawer (renderer ) as draw_path :
550
+
551
+ # Patch has traditionally ignored the dashoffset.
552
+ with cbook ._setattr_cm (self , _dashoffset = 0 ), \
553
+ self ._bind_draw_path_function (renderer ) as draw_path :
550
554
path = self .get_path ()
551
555
transform = self .get_transform ()
552
556
tpath = transform .transform_path_non_affine (path )
@@ -4277,9 +4281,9 @@ def draw(self, renderer):
4277
4281
if not self .get_visible ():
4278
4282
return
4279
4283
4280
- # FancyArrowPatch have traditionally forced the capstyle and joinstyle.
4284
+ # FancyArrowPatch has traditionally forced the capstyle and joinstyle.
4281
4285
with cbook ._setattr_cm (self , _capstyle = 'round' , _joinstyle = 'round' ), \
4282
- self ._prepare_path_drawer (renderer ) as draw_path :
4286
+ self ._bind_draw_path_function (renderer ) as draw_path :
4283
4287
4284
4288
# FIXME : dpi_cor is for the dpi-dependecy of the linewidth. There
4285
4289
# could be room for improvement.
@@ -4293,7 +4297,9 @@ def draw(self, renderer):
4293
4297
affine = transforms .IdentityTransform ()
4294
4298
4295
4299
for p , f in zip (path , fillable ):
4296
- draw_path (p , affine , self ._facecolor if f else None )
4300
+ draw_path (
4301
+ p , affine ,
4302
+ self ._facecolor if f and self ._facecolor [3 ] else None )
4297
4303
4298
4304
4299
4305
class ConnectionPatch (FancyArrowPatch ):
0 commit comments