Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cd979de

Browse files
committed
Address review comments.
1 parent f574cf2 commit cd979de

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

lib/matplotlib/patches.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -481,13 +481,14 @@ def get_hatch(self):
481481
return self._hatch
482482

483483
@contextlib.contextmanager
484-
def _prepare_path_drawer(self, renderer):
484+
def _bind_draw_path_function(self, renderer):
485485
"""
486486
``draw()`` helper factored out for sharing with `FancyArrowPatch`.
487487
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.
491492
"""
492493

493494
renderer.open_group('patch', self.get_gid())
@@ -499,7 +500,7 @@ def _prepare_path_drawer(self, renderer):
499500
if self._edgecolor[3] == 0:
500501
lw = 0
501502
gc.set_linewidth(lw)
502-
gc.set_dashes(0, self._dashes)
503+
gc.set_dashes(self._dashoffset, self._dashes)
503504
gc.set_capstyle(self._capstyle)
504505
gc.set_joinstyle(self._joinstyle)
505506

@@ -530,7 +531,7 @@ def _prepare_path_drawer(self, renderer):
530531
from matplotlib.patheffects import PathEffectRenderer
531532
renderer = PathEffectRenderer(self.get_path_effects(), renderer)
532533

533-
# In `with _prepare_path_drawer(renderer) as draw_path: draw_path(...)`
534+
# In `with _bind_draw_path_function(renderer) as draw_path: ...`
534535
# (in the implementations of `draw()` below), calls to `draw_path(...)`
535536
# will occur as if they took place here with `gc` inserted as
536537
# additional first argument.
@@ -546,7 +547,10 @@ def draw(self, renderer):
546547
if not self.get_visible():
547548
return
548549

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:
550554
path = self.get_path()
551555
transform = self.get_transform()
552556
tpath = transform.transform_path_non_affine(path)
@@ -4277,9 +4281,9 @@ def draw(self, renderer):
42774281
if not self.get_visible():
42784282
return
42794283

4280-
# FancyArrowPatch have traditionally forced the capstyle and joinstyle.
4284+
# FancyArrowPatch has traditionally forced the capstyle and joinstyle.
42814285
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:
42834287

42844288
# FIXME : dpi_cor is for the dpi-dependecy of the linewidth. There
42854289
# could be room for improvement.
@@ -4293,7 +4297,9 @@ def draw(self, renderer):
42934297
affine = transforms.IdentityTransform()
42944298

42954299
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)
42974303

42984304

42994305
class ConnectionPatch(FancyArrowPatch):

0 commit comments

Comments
 (0)