@@ -52,11 +52,16 @@ class Collection(artist.Artist, cm.ScalarMappable):
52
52
53
53
prop[i % len(props)]
54
54
55
+ Exceptions are *capstyle* and *joinstyle* properties, these can
56
+ only be set globally for the whole collection.
57
+
55
58
Keyword arguments and default values:
56
59
57
60
* *edgecolors*: None
58
61
* *facecolors*: None
59
62
* *linewidths*: None
63
+ * *capstyle*: None
64
+ * *joinstyle*: None
60
65
* *antialiaseds*: None
61
66
* *offsets*: None
62
67
* *transOffset*: transforms.IdentityTransform()
@@ -104,6 +109,8 @@ def __init__(self,
104
109
facecolors = None ,
105
110
linewidths = None ,
106
111
linestyles = 'solid' ,
112
+ capstyle = None ,
113
+ joinstyle = None ,
107
114
antialiaseds = None ,
108
115
offsets = None ,
109
116
transOffset = None ,
@@ -145,6 +152,16 @@ def __init__(self,
145
152
self .set_offset_position (offset_position )
146
153
self .set_zorder (zorder )
147
154
155
+ if capstyle :
156
+ self .set_capstyle (capstyle )
157
+ else :
158
+ self ._capstyle = None
159
+
160
+ if joinstyle :
161
+ self .set_joinstyle (joinstyle )
162
+ else :
163
+ self ._joinstyle = None
164
+
148
165
self ._offsets = np .zeros ((1 , 2 ))
149
166
self ._uniform_offsets = None
150
167
if offsets is not None :
@@ -304,6 +321,12 @@ def draw(self, renderer):
304
321
extents .height < height ):
305
322
do_single_path_optimization = True
306
323
324
+ if self ._joinstyle :
325
+ gc .set_joinstyle (self ._joinstyle )
326
+
327
+ if self ._capstyle :
328
+ gc .set_capstyle (self ._capstyle )
329
+
307
330
if do_single_path_optimization :
308
331
gc .set_foreground (tuple (edgecolors [0 ]))
309
332
gc .set_linewidth (self ._linewidths [0 ])
@@ -536,6 +559,42 @@ def set_linestyle(self, ls):
536
559
self ._linewidths , self ._linestyles = self ._bcast_lwls (
537
560
self ._us_lw , self ._us_linestyles )
538
561
562
+ def set_capstyle (self , cs ):
563
+ """
564
+ Set the capstyle for the collection. The capstyle can
565
+ only be set globally for all elements in the collection
566
+
567
+ Parameters
568
+ ----------
569
+ cs : ['butt' | 'round' | 'projecting']
570
+ The capstyle
571
+ """
572
+ if cs in ('butt' , 'round' , 'projecting' ):
573
+ self ._capstyle = cs
574
+ else :
575
+ raise ValueError ('Unrecognized cap style. Found %s' % cs )
576
+
577
+ def get_capstyle (self ):
578
+ return self ._capstyle
579
+
580
+ def set_joinstyle (self , js ):
581
+ """
582
+ Set the joinstyle for the collection. The joinstyle can only be
583
+ set globally for all elements in the collection.
584
+
585
+ Parameters
586
+ ----------
587
+ js : ['miter' | 'round' | 'bevel']
588
+ The joinstyle
589
+ """
590
+ if js in ('miter' , 'round' , 'bevel' ):
591
+ self ._joinstyle = js
592
+ else :
593
+ raise ValueError ('Unrecognized join style. Found %s' % js )
594
+
595
+ def get_joinstyle (self ):
596
+ return self ._joinstyle
597
+
539
598
@staticmethod
540
599
def _bcast_lwls (linewidths , dashes ):
541
600
'''Internal helper function to broadcast + scale ls/lw
0 commit comments