@@ -97,9 +97,10 @@ def __init__(self,
97
97
else :
98
98
self .set_edgecolor (edgecolor )
99
99
self .set_facecolor (facecolor )
100
- # unscaled dashes. Needed to scale dash patterns by lw
101
- self ._us_dashes = None
100
+
102
101
self ._linewidth = 0
102
+ self ._unscaled_dash_pattern = (0 , None ) # offset, dash
103
+ self ._dash_pattern = (0 , None ) # offset, dash (scaled by linewidth)
103
104
104
105
self .set_fill (fill )
105
106
self .set_linestyle (linestyle )
@@ -259,9 +260,8 @@ def update_from(self, other):
259
260
self ._fill = other ._fill
260
261
self ._hatch = other ._hatch
261
262
self ._hatch_color = other ._hatch_color
262
- # copy the unscaled dash pattern
263
- self ._us_dashes = other ._us_dashes
264
- self .set_linewidth (other ._linewidth ) # also sets dash properties
263
+ self ._unscaled_dash_pattern = other ._unscaled_dash_pattern
264
+ self .set_linewidth (other ._linewidth ) # also sets scaled dashes
265
265
self .set_transform (other .get_data_transform ())
266
266
# If the transform of other needs further initialization, then it will
267
267
# be the case for this artist too.
@@ -407,12 +407,9 @@ def set_linewidth(self, w):
407
407
w = mpl .rcParams ['patch.linewidth' ]
408
408
if w is None :
409
409
w = mpl .rcParams ['axes.linewidth' ]
410
-
411
410
self ._linewidth = float (w )
412
- # scale the dash pattern by the linewidth
413
- offset , ls = self ._us_dashes
414
- self ._dashoffset , self ._dashes = mlines ._scale_dashes (
415
- offset , ls , self ._linewidth )
411
+ self ._dash_pattern = mlines ._scale_dashes (
412
+ * self ._unscaled_dash_pattern , w )
416
413
self .stale = True
417
414
418
415
def set_linestyle (self , ls ):
@@ -445,11 +442,9 @@ def set_linestyle(self, ls):
445
442
if ls in [' ' , '' , 'none' ]:
446
443
ls = 'None'
447
444
self ._linestyle = ls
448
- # get the unscaled dash pattern
449
- offset , ls = self ._us_dashes = mlines ._get_dash_pattern (ls )
450
- # scale the dash pattern by the linewidth
451
- self ._dashoffset , self ._dashes = mlines ._scale_dashes (
452
- offset , ls , self ._linewidth )
445
+ self ._unscaled_dash_pattern = mlines ._get_dash_pattern (ls )
446
+ self ._dash_pattern = mlines ._scale_dashes (
447
+ * self ._unscaled_dash_pattern , self ._linewidth )
453
448
self .stale = True
454
449
455
450
def set_fill (self , b ):
@@ -565,7 +560,7 @@ def _bind_draw_path_function(self, renderer):
565
560
if self ._edgecolor [3 ] == 0 or self ._linestyle == 'None' :
566
561
lw = 0
567
562
gc .set_linewidth (lw )
568
- gc .set_dashes (self ._dashoffset , self . _dashes )
563
+ gc .set_dashes (* self ._dash_pattern )
569
564
gc .set_capstyle (self ._capstyle )
570
565
gc .set_joinstyle (self ._joinstyle )
571
566
@@ -603,8 +598,9 @@ def draw(self, renderer):
603
598
if not self .get_visible ():
604
599
return
605
600
# Patch has traditionally ignored the dashoffset.
606
- with cbook ._setattr_cm (self , _dashoffset = 0 ), \
607
- self ._bind_draw_path_function (renderer ) as draw_path :
601
+ with cbook ._setattr_cm (
602
+ self , _dash_pattern = (0 , self ._dash_pattern [1 ])), \
603
+ self ._bind_draw_path_function (renderer ) as draw_path :
608
604
path = self .get_path ()
609
605
transform = self .get_transform ()
610
606
tpath = transform .transform_path_non_affine (path )
0 commit comments