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 ):
@@ -403,7 +397,7 @@ def draw(self, renderer):
403
397
if do_single_path_optimization :
404
398
gc .set_foreground (tuple (edgecolors [0 ]))
405
399
gc .set_linewidth (self ._linewidths [0 ])
406
- gc .set_dashes (* self ._linestyles [0 ])
400
+ gc .set_dashes (* self ._dash_patterns [0 ])
407
401
gc .set_antialiased (self ._antialiaseds [0 ])
408
402
gc .set_url (self ._urls [0 ])
409
403
renderer .draw_markers (
@@ -414,7 +408,7 @@ def draw(self, renderer):
414
408
gc , transform .frozen (), paths ,
415
409
self .get_transforms (), offsets , offset_trf ,
416
410
self .get_facecolor (), self .get_edgecolor (),
417
- self ._linewidths , self ._linestyles ,
411
+ self ._linewidths , self ._dash_patterns ,
418
412
self ._antialiaseds , self ._urls ,
419
413
"screen" ) # offset_position, kept for backcompat.
420
414
@@ -575,59 +569,75 @@ def set_linewidth(self, lw):
575
569
if lw is None :
576
570
lw = self ._get_default_linewidth ()
577
571
# get the un-scaled/broadcast lw
578
- self ._us_lw = np .atleast_1d (np .asarray (lw ))
572
+ self ._unscaled_lw = np .atleast_1d (np .asarray (lw ))
579
573
580
574
# scale all of the dash patterns.
581
- self ._linewidths , self ._linestyles = self ._bcast_lwls (
582
- self ._us_lw , self ._us_linestyles )
575
+ self ._linewidths , self ._dash_patterns = self ._bcast_lwls (
576
+ self ._unscaled_lw , self ._unscaled_dash_patterns )
583
577
self .stale = True
584
578
585
579
def set_linestyle (self , ls ):
586
580
"""
587
- Set the linestyle(s) for the collection.
581
+ Set the line style(s) for the collection.
582
+
583
+ Parameters
584
+ ----------
585
+ ls : str or tuple or list thereof
586
+ The line style. Possible values:
588
587
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
- =========================== =================
588
+ - A string:
597
589
598
- Alternatively a dash tuple of the following form can be provided::
590
+ ========================================== =================
591
+ linestyle description
592
+ ========================================== =================
593
+ ``'-'`` or ``'solid'`` solid line
594
+ ``'--'`` or ``'dashed'`` dashed line
595
+ ``'-.'`` or ``'dashdot'`` dash-dotted line
596
+ ``':'`` or ``'dotted'`` dotted line
597
+ ``'none'``, ``'None'``, ``' '``, or ``''`` draw nothing
598
+ ========================================== =================
599
599
600
- (offset, onoffseq),
600
+ - Alternatively a dash tuple of the following form can be
601
+ provided::
601
602
602
- where ``onoffseq`` is an even length tuple of on and off ink in points.
603
+ (offset, onoffseq)
603
604
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 ]
605
+ where ``onoffseq`` is an even length tuple of on and off ink
606
+ in points.
620
607
621
- except ValueError as err :
622
- raise ValueError ('Do not know how to convert {!r} to '
623
- 'dashes' .format (ls )) from err
608
+ If a single value is provided, this applies to all objects in the
609
+ collection. A list can be provided to set different line styles to
610
+ different objects.
611
+
612
+ For examples see :doc:`/gallery/lines_bars_and_markers/linestyles`.
613
+
614
+ The ``'dashed'``, ``'dashdot'``, and ``'dotted'`` line styles are
615
+ controlled by :rc:`lines.dashed_pattern`,
616
+ :rc:`lines.dashdot_pattern`, and :rc:`lines.dotted_pattern`,
617
+ respectively.
618
+ """
619
+ if isinstance (ls , str ):
620
+ dashes , ls_norm = map (list , zip (mlines ._get_dash_pattern (ls )))
621
+ else :
622
+ try :
623
+ dashes , ls_norm = map (list , zip (mlines ._get_dash_pattern (ls )))
624
+ except ValueError :
625
+ dashes , ls_norm = map (
626
+ list , zip (* [mlines ._get_dash_pattern (x ) for x in ls ]))
624
627
625
628
# get the list of raw 'unscaled' dash patterns
626
- self ._us_linestyles = dashes
629
+ self ._unscaled_dash_patterns = dashes
627
630
628
631
# broadcast and scale the lw and dash patterns
629
- self ._linewidths , self ._linestyles = self ._bcast_lwls (
630
- self ._us_lw , self ._us_linestyles )
632
+ self ._linewidths , self ._dash_patterns = self ._bcast_lwls (
633
+ self ._unscaled_lw , self ._unscaled_dash_patterns )
634
+ self ._linestyles = ls_norm
635
+
636
+ def get_dashes (self ):
637
+ """
638
+ Return the dash patterns.
639
+ """
640
+ return self ._dash_patterns
631
641
632
642
@_docstring .interpd
633
643
def set_capstyle (self , cs ):
@@ -919,8 +929,10 @@ def update_from(self, other):
919
929
self ._original_facecolor = other ._original_facecolor
920
930
self ._facecolors = other ._facecolors
921
931
self ._linewidths = other ._linewidths
932
+ self ._unscaled_lw = other ._unscaled_lw
922
933
self ._linestyles = other ._linestyles
923
- self ._us_linestyles = other ._us_linestyles
934
+ self ._unscaled_dash_patterns = other ._unscaled_dash_patterns
935
+ self ._dash_patterns = other ._dash_patterns
924
936
self ._pickradius = other ._pickradius
925
937
self ._hatch = other ._hatch
926
938
@@ -1522,7 +1534,7 @@ def __init__(self,
1522
1534
linelength = 1 ,
1523
1535
linewidth = None ,
1524
1536
color = None ,
1525
- linestyle = 'solid ' ,
1537
+ linestyle = '- ' ,
1526
1538
antialiased = None ,
1527
1539
** kwargs
1528
1540
):
@@ -1545,14 +1557,8 @@ def __init__(self,
1545
1557
The line width of the event lines, in points.
1546
1558
color : color or list of colors, default: :rc:`lines.color`
1547
1559
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.
1560
+ linestyle : str or tuple or list thereof, default: '-'
1561
+ Line style or list of line styles. See `set_linestyle` for details.
1556
1562
antialiased : bool or list thereof, default: :rc:`lines.antialiased`
1557
1563
Whether to use antialiasing for drawing the lines.
1558
1564
**kwargs
0 commit comments