@@ -314,7 +314,7 @@ def set_antialiased(self, aa):
314314 self ._antialiased = aa
315315 self .stale = True
316316
317- def _set_edgecolor (self , color ):
317+ def _set_edgecolor (self , color , edge_alpha = 0 ):
318318 set_hatch_color = True
319319 if color is None :
320320 if (mpl .rcParams ['patch.force_edgecolor' ] or
@@ -323,8 +323,10 @@ def _set_edgecolor(self, color):
323323 else :
324324 color = 'none'
325325 set_hatch_color = False
326-
327- self ._edgecolor = colors .to_rgba (color , self ._alpha )
326+ if edge_alpha :
327+ self ._edgecolor = colors .to_rgba (color , edge_alpha )
328+ else :
329+ self ._edgecolor = colors .to_rgba (color , self ._alpha )
328330 if set_hatch_color :
329331 self ._hatch_color = self ._edgecolor
330332 self .stale = True
@@ -340,10 +342,13 @@ def set_edgecolor(self, color):
340342 self ._original_edgecolor = color
341343 self ._set_edgecolor (color )
342344
343- def _set_facecolor (self , color ):
345+ def _set_facecolor (self , color , face_alpha = 0 ):
344346 if color is None :
345347 color = mpl .rcParams ['patch.facecolor' ]
346- alpha = self ._alpha if self ._fill else 0
348+ if face_alpha and self ._fill :
349+ alpha = face_alpha
350+ else :
351+ alpha = self ._alpha if self ._fill else 0
347352 self ._facecolor = colors .to_rgba (color , alpha )
348353 self .stale = True
349354
@@ -375,11 +380,37 @@ def set_color(self, c):
375380 self .set_edgecolor (c )
376381
377382 def set_alpha (self , alpha ):
378- # docstring inherited
379- super ().set_alpha (alpha )
380- self ._set_facecolor (self ._original_facecolor )
381- self ._set_edgecolor (self ._original_edgecolor )
382- # stale is already True
383+ """
384+ Set the alpha value used for blending.
385+
386+ Parameters
387+ ----------
388+ alpha : scalar or None or tuple of scalars
389+ *alpha* must be within the 0-1 range, inclusive.
390+ """
391+ is_alpha_valid_tuple = False
392+ if isinstance (alpha , tuple ):
393+ if len (alpha ) != 2 :
394+ raise ValueError ('If given as a tuple, alpha must contain two '
395+ 'numbers, the face and edge alpha values' )
396+ for item in alpha :
397+ if not isinstance (item , Number ):
398+ raise TypeError ('Alpha values must be numbers between 0 '
399+ 'and 1, inclusive' )
400+ if not (0 <= item <= 1 ):
401+ raise ValueError ('Alpha values must be between 0 and 1, '
402+ 'inclusive' )
403+ is_alpha_valid_tuple = True
404+ if is_alpha_valid_tuple :
405+ face_alpha = alpha [0 ]
406+ edge_alpha = alpha [1 ]
407+ self ._set_facecolor (self ._original_facecolor , face_alpha )
408+ self ._set_edgecolor (self ._original_edgecolor , edge_alpha )
409+ else :
410+ super ().set_alpha (alpha )
411+ self ._set_facecolor (self ._original_facecolor )
412+ self ._set_edgecolor (self ._original_edgecolor )
413+ # stale is already True
383414
384415 def set_linewidth (self , w ):
385416 """
0 commit comments