28
28
"antialiased" : ["antialiaseds" , "aa" ],
29
29
"edgecolor" : ["edgecolors" , "ec" ],
30
30
"facecolor" : ["facecolors" , "fc" ],
31
- "linestyle" : ["linestyles" , "dashes" , " ls" ],
31
+ "linestyle" : ["linestyles" , "ls" ],
32
32
"linewidth" : ["linewidths" , "lw" ],
33
33
"offset_transform" : ["transOffset" ],
34
34
})
@@ -79,7 +79,7 @@ def __init__(self,
79
79
edgecolors = None ,
80
80
facecolors = None ,
81
81
linewidths = None ,
82
- linestyles = 'solid ' ,
82
+ linestyles = '- ' ,
83
83
capstyle = None ,
84
84
joinstyle = None ,
85
85
antialiaseds = None ,
@@ -105,15 +105,8 @@ def __init__(self,
105
105
Face color for each patch making up the collection.
106
106
linewidths : float or list of floats, default: :rc:`patch.linewidth`
107
107
Line width for each patch making up the collection.
108
- linestyles : str or tuple or list thereof, default: 'solid'
109
- Valid strings are ['solid', 'dashed', 'dashdot', 'dotted', '-',
110
- '--', '-.', ':']. Dash tuples should be of the form::
111
-
112
- (offset, onoffseq),
113
-
114
- where *onoffseq* is an even length tuple of on and off ink lengths
115
- in points. For examples, see
116
- :doc:`/gallery/lines_bars_and_markers/linestyles`.
108
+ linestyles : str or tuple or list thereof, default: '-'
109
+ Line style or list of line styles. See `set_linestyle` for details.
117
110
capstyle : `.CapStyle`-like, default: :rc:`patch.capstyle`
118
111
Style to use for capping lines for all paths in the collection.
119
112
Allowed values are %(CapStyle)s.
@@ -161,11 +154,12 @@ def __init__(self,
161
154
cm .ScalarMappable .__init__ (self , norm , cmap )
162
155
# list of un-scaled dash patterns
163
156
# this is needed scaling the dash pattern by linewidth
164
- self ._us_linestyles = [(0 , None )]
157
+ self ._unscaled_dash_patterns = [(0 , None )]
165
158
# list of dash patterns
166
- self ._linestyles = [(0 , None )]
159
+ self ._dash_patterns = [(0 , None )]
160
+ self ._linestyles = ['-' ]
167
161
# list of unbroadcast/scaled linewidths
168
- self ._us_lw = [0 ]
162
+ self ._unscaled_lw = [0 ]
169
163
self ._linewidths = [0 ]
170
164
# Flags set by _set_mappable_flags: are colors from mapping an array?
171
165
self ._face_is_mapped = None
@@ -382,7 +376,7 @@ def draw(self, renderer):
382
376
if (len (paths ) == 1 and len (trans ) <= 1 and
383
377
len (facecolors ) == 1 and len (edgecolors ) == 1 and
384
378
len (self ._linewidths ) == 1 and
385
- all (ls [1 ] is None for ls in self ._linestyles ) and
379
+ all (dash [1 ] is None for dash in self ._dash_patterns ) and
386
380
len (self ._antialiaseds ) == 1 and len (self ._urls ) == 1 and
387
381
self .get_hatch () is None ):
388
382
if len (trans ):
@@ -400,21 +394,23 @@ def draw(self, renderer):
400
394
if self ._capstyle :
401
395
gc .set_capstyle (self ._capstyle )
402
396
397
+ print (do_single_path_optimization )
403
398
if do_single_path_optimization :
404
399
gc .set_foreground (tuple (edgecolors [0 ]))
405
400
gc .set_linewidth (self ._linewidths [0 ])
406
- gc .set_dashes (* self ._linestyles [0 ])
401
+ gc .set_dashes (* self ._dash_patterns [0 ])
407
402
gc .set_antialiased (self ._antialiaseds [0 ])
408
403
gc .set_url (self ._urls [0 ])
409
404
renderer .draw_markers (
410
405
gc , paths [0 ], combined_transform .frozen (),
411
406
mpath .Path (offsets ), offset_trf , tuple (facecolors [0 ]))
412
407
else :
408
+ print (self ._linewidths )
413
409
renderer .draw_path_collection (
414
410
gc , transform .frozen (), paths ,
415
411
self .get_transforms (), offsets , offset_trf ,
416
412
self .get_facecolor (), self .get_edgecolor (),
417
- self ._linewidths , self ._linestyles ,
413
+ self ._linewidths , self ._dash_patterns ,
418
414
self ._antialiaseds , self ._urls ,
419
415
"screen" ) # offset_position, kept for backcompat.
420
416
@@ -575,59 +571,75 @@ def set_linewidth(self, lw):
575
571
if lw is None :
576
572
lw = self ._get_default_linewidth ()
577
573
# get the un-scaled/broadcast lw
578
- self ._us_lw = np .atleast_1d (np .asarray (lw ))
574
+ self ._unscaled_lw = np .atleast_1d (np .asarray (lw ))
579
575
580
576
# scale all of the dash patterns.
581
- self ._linewidths , self ._linestyles = self ._bcast_lwls (
582
- self ._us_lw , self ._us_linestyles )
577
+ self ._linewidths , self ._dash_patterns = self ._bcast_lwls (
578
+ self ._unscaled_lw , self ._unscaled_dash_patterns )
583
579
self .stale = True
584
580
585
581
def set_linestyle (self , ls ):
586
582
"""
587
- Set the linestyle(s) for the collection.
583
+ Set the line style(s) for the collection.
584
+
585
+ Parameters
586
+ ----------
587
+ ls : str or tuple or list thereof
588
+ The line style. Possible values:
588
589
589
- =========================== =================
590
- linestyle description
591
- =========================== =================
592
- ``'-'`` or ``'solid'`` solid line
593
- ``'--'`` or ``'dashed'`` dashed line
594
- ``'-.'`` or ``'dashdot'`` dash-dotted line
595
- ``':'`` or ``'dotted'`` dotted line
596
- =========================== =================
590
+ - A string:
597
591
598
- Alternatively a dash tuple of the following form can be provided::
592
+ ========================================== =================
593
+ linestyle description
594
+ ========================================== =================
595
+ ``'-'`` or ``'solid'`` solid line
596
+ ``'--'`` or ``'dashed'`` dashed line
597
+ ``'-.'`` or ``'dashdot'`` dash-dotted line
598
+ ``':'`` or ``'dotted'`` dotted line
599
+ ``'none'``, ``'None'``, ``' '``, or ``''`` draw nothing
600
+ ========================================== =================
599
601
600
- (offset, onoffseq),
602
+ - Alternatively a dash tuple of the following form can be
603
+ provided::
601
604
602
- where ``onoffseq`` is an even length tuple of on and off ink in points.
605
+ (offset, onoffseq)
603
606
604
- Parameters
605
- ----------
606
- ls : str or tuple or list thereof
607
- Valid values for individual linestyles include {'-', '--', '-.',
608
- ':', '', (offset, on-off-seq)}. See `.Line2D.set_linestyle` for a
609
- complete description.
610
- """
611
- try :
612
- if isinstance (ls , str ):
613
- ls = cbook .ls_mapper .get (ls , ls )
614
- dashes = [mlines ._get_dash_pattern (ls )]
615
- else :
616
- try :
617
- dashes = [mlines ._get_dash_pattern (ls )]
618
- except ValueError :
619
- dashes = [mlines ._get_dash_pattern (x ) for x in ls ]
607
+ where ``onoffseq`` is an even length tuple of on and off ink
608
+ in points.
620
609
621
- except ValueError as err :
622
- raise ValueError ('Do not know how to convert {!r} to '
623
- 'dashes' .format (ls )) from err
610
+ If a single value is provided, this applies to all objects in the
611
+ collection. A list can be provided to set different line styles to
612
+ different objects.
613
+
614
+ For examples see :doc:`/gallery/lines_bars_and_markers/linestyles`.
615
+
616
+ The ``'dashed'``, ``'dashdot'``, and ``'dotted'`` line styles are
617
+ controlled by :rc:`lines.dashed_pattern`,
618
+ :rc:`lines.dashdot_pattern`, and :rc:`lines.dotted_pattern`,
619
+ respectively.
620
+ """
621
+ if isinstance (ls , str ):
622
+ dashes , ls_norm = map (list , zip (mlines ._get_dash_pattern (ls )))
623
+ else :
624
+ try :
625
+ dashes , ls_norm = map (list , zip (mlines ._get_dash_pattern (ls )))
626
+ except ValueError :
627
+ dashes , ls_norm = map (
628
+ list , zip (* [mlines ._get_dash_pattern (x ) for x in ls ]))
624
629
625
630
# get the list of raw 'unscaled' dash patterns
626
- self ._us_linestyles = dashes
631
+ self ._unscaled_dash_patterns = dashes
627
632
628
633
# broadcast and scale the lw and dash patterns
629
- self ._linewidths , self ._linestyles = self ._bcast_lwls (
630
- self ._us_lw , self ._us_linestyles )
634
+ self ._linewidths , self ._dash_patterns = self ._bcast_lwls (
635
+ self ._unscaled_lw , self ._unscaled_dash_patterns )
636
+ self ._linestyles = ls_norm
637
+
638
+ def get_dashes (self ):
639
+ """
640
+ Return the dash patterns.
641
+ """
642
+ return self ._dash_patterns
631
643
632
644
@_docstring .interpd
633
645
def set_capstyle (self , cs ):
@@ -919,8 +931,10 @@ def update_from(self, other):
919
931
self ._original_facecolor = other ._original_facecolor
920
932
self ._facecolors = other ._facecolors
921
933
self ._linewidths = other ._linewidths
934
+ self ._unscaled_lw = other ._unscaled_lw
922
935
self ._linestyles = other ._linestyles
923
- self ._us_linestyles = other ._us_linestyles
936
+ self ._unscaled_dash_patterns = other ._unscaled_dash_patterns
937
+ self ._dash_patterns = other ._dash_patterns
924
938
self ._pickradius = other ._pickradius
925
939
self ._hatch = other ._hatch
926
940
@@ -1522,7 +1536,7 @@ def __init__(self,
1522
1536
linelength = 1 ,
1523
1537
linewidth = None ,
1524
1538
color = None ,
1525
- linestyle = 'solid ' ,
1539
+ linestyle = '- ' ,
1526
1540
antialiased = None ,
1527
1541
** kwargs
1528
1542
):
@@ -1545,14 +1559,8 @@ def __init__(self,
1545
1559
The line width of the event lines, in points.
1546
1560
color : color or list of colors, default: :rc:`lines.color`
1547
1561
The color of the event lines.
1548
- linestyle : str or tuple or list thereof, default: 'solid'
1549
- Valid strings are ['solid', 'dashed', 'dashdot', 'dotted',
1550
- '-', '--', '-.', ':']. Dash tuples should be of the form::
1551
-
1552
- (offset, onoffseq),
1553
-
1554
- where *onoffseq* is an even length tuple of on and off ink
1555
- in points.
1562
+ linestyle : str or tuple or list thereof, default: '-'
1563
+ Line style or list of line styles. See `set_linestyle` for details.
1556
1564
antialiased : bool or list thereof, default: :rc:`lines.antialiased`
1557
1565
Whether to use antialiasing for drawing the lines.
1558
1566
**kwargs
0 commit comments