30
30
alpha float
31
31
animated [True | False]
32
32
antialiased or aa [True | False]
33
+ capstyle ['butt' | 'round' | 'projecting']
33
34
clip_box a matplotlib.transform.Bbox instance
34
35
clip_on [True | False]
35
36
edgecolor or ec any matplotlib color
36
37
facecolor or fc any matplotlib color
37
38
figure a matplotlib.figure.Figure instance
38
39
fill [True | False]
39
40
hatch unknown
41
+ joinstyle ['miter' | 'round' | 'bevel']
40
42
label any string
41
43
linewidth or lw float
42
44
lod [True | False]
@@ -56,6 +58,8 @@ class Patch(artist.Artist):
56
58
are *None*, they default to their rc params setting.
57
59
"""
58
60
zorder = 1
61
+ validCap = ('butt' , 'round' , 'projecting' )
62
+ validJoin = ('miter' , 'round' , 'bevel' )
59
63
60
64
def __str__ (self ):
61
65
return str (self .__class__ ).split ('.' )[- 1 ]
@@ -69,6 +73,8 @@ def __init__(self,
69
73
antialiased = None ,
70
74
hatch = None ,
71
75
fill = True ,
76
+ capstyle = None ,
77
+ joinstyle = None ,
72
78
** kwargs ):
73
79
"""
74
80
The following kwarg properties are supported
@@ -81,6 +87,10 @@ def __init__(self,
81
87
linewidth = mpl .rcParams ['patch.linewidth' ]
82
88
if linestyle is None :
83
89
linestyle = "solid"
90
+ if capstyle is None :
91
+ capstyle = 'butt'
92
+ if joinstyle is None :
93
+ joinstyle = 'miter'
84
94
if antialiased is None :
85
95
antialiased = mpl .rcParams ['patch.antialiased' ]
86
96
@@ -100,6 +110,8 @@ def __init__(self,
100
110
self .set_antialiased (antialiased )
101
111
self .set_hatch (hatch )
102
112
self .set_fill (fill )
113
+ self .set_capstyle (capstyle )
114
+ self .set_joinstyle (joinstyle )
103
115
self ._combined_transform = transforms .IdentityTransform ()
104
116
105
117
if len (kwargs ):
@@ -355,6 +367,38 @@ def get_fill(self):
355
367
# attribute.
356
368
fill = property (get_fill , set_fill )
357
369
370
+ def set_capstyle (self , s ):
371
+ """
372
+ Set the patch capstyle
373
+
374
+ ACCEPTS: ['butt' | 'round' | 'projecting']
375
+ """
376
+ s = s .lower ()
377
+ if s not in self .validCap :
378
+ raise ValueError ('set_capstyle passed "%s";\n ' % (s ,)
379
+ + 'valid capstyles are %s' % (self .validCap ,))
380
+ self ._capstyle = s
381
+
382
+ def get_capstyle (self ):
383
+ "Return the current capstyle"
384
+ return self ._capstyle
385
+
386
+ def set_joinstyle (self , s ):
387
+ """
388
+ Set the patch joinstyle
389
+
390
+ ACCEPTS: ['miter' | 'round' | 'bevel']
391
+ """
392
+ s = s .lower ()
393
+ if s not in self .validJoin :
394
+ raise ValueError ('set_joinstyle passed "%s";\n ' % (s ,)
395
+ + 'valid joinstyles are %s' % (self .validJoin ,))
396
+ self ._joinstyle = s
397
+
398
+ def get_joinstyle (self ):
399
+ "Return the current joinstyle"
400
+ return self ._joinstyle
401
+
358
402
def set_hatch (self , hatch ):
359
403
"""
360
404
Set the hatching pattern
@@ -403,6 +447,8 @@ def draw(self, renderer):
403
447
lw = 0
404
448
gc .set_linewidth (lw )
405
449
gc .set_linestyle (self ._linestyle )
450
+ gc .set_capstyle (self ._capstyle )
451
+ gc .set_joinstyle (self ._joinstyle )
406
452
407
453
gc .set_antialiased (self ._antialiased )
408
454
self ._set_gc_clip (gc )
0 commit comments