8000 Merge pull request #7253 from tacaswell/fix_fancyarrow_dash · matplotlib/matplotlib@aad8dc5 · GitHub
[go: up one dir, main page]

Skip to content

Commit aad8dc5

Browse files
authored
Merge pull request #7253 from tacaswell/fix_fancyarrow_dash
FIX: fix FancyArrowPatch linestyle
2 parents fc88474 + daa9394 commit aad8dc5

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

lib/matplotlib/patches.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,8 @@ def set_linewidth(self, w):
372372
self._linewidth = float(w)
373373
# scale the dash pattern by the linewidth
374374
offset, ls = self._us_dashes
375-
self._dashes = mlines._scale_dashes(offset,
376-
ls,
377-
self._linewidth)[1]
375+
self._dashoffset, self._dashes = mlines._scale_dashes(
376+
offset, ls, self._linewidth)
378377
self.stale = True
379378

380379
def set_lw(self, lw):
@@ -417,9 +416,8 @@ def set_linestyle(self, ls):
417416
# get the unscalled dash pattern
418417
offset, ls = self._us_dashes = mlines._get_dash_pattern(ls)
419418
# scale the dash pattern by the linewidth
420-
self._dashes = mlines._scale_dashes(offset,
421-
ls,
422-
self._linewidth)[1]
419+
self._dashoffset, self._dashes = mlines._scale_dashes(
420+
offset, ls, self._linewidth)
423421
self.stale = True
424422

425423
def set_ls(self, ls):
@@ -4271,7 +4269,7 @@ def draw(self, renderer):
42714269
if self._edgecolor[3] == 0:
42724270
lw = 0
42734271
gc.set_linewidth(lw)
4274-
gc.set_linestyle(self._linestyle)
4272+
gc.set_dashes(self._dashoffset, self._dashes)
42754273

42764274
gc.set_antialiased(self._antialiased)
42774275
self._set_gc_clip(gc)
Loading

lib/matplotlib/tests/test_arrow_patches.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,32 @@ def test_fancyarrow_dpi_cor_200dpi():
9797
__prepare_fancyarrow_dpi_cor_test()
9898

9999

100+
@image_comparison(baseline_images=['fancyarrow_dash'],
101+
remove_text=True, extensions=['png'],
102+
style='default')
103+
def test_fancyarrow_dash():
104+
from matplotlib.patches import FancyArrowPatch
105+
fig, ax = plt.subplots()
106+
107+
e = FancyArrowPatch((0, 0), (0.5, 0.5),
108+
arrowstyle='-|>',
109+
connectionstyle='angle3,angleA=0,angleB=90',
110+
mutation_scale=10.0,
111+
linewidth=2,
112+
linestyle='dashed',
113+
color='k')
114+
115+
e2 = FancyArrowPatch((0, 0), (0.5, 0.5),
116+
arrowstyle='-|>',
117+
connectionstyle='angle3',
118+
mutation_scale=10.0,
119+
linewidth=2,
120+
linestyle='dotted',
121+
color='k')
122+
ax.add_patch(e)
123+
ax.add_patch(e2)
124+
125+
100126
if __name__ == '__main__':
101127
import nose
102128
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

0 commit comments

Comments
 (0)
0