@@ -742,8 +742,7 @@ def get_linewidth(self):
742742
743743 def get_rgb (self ):
744744 """
745- returns a tuple of three floats from 0-1. color can be a
746- MATLAB format string, a html hex color string, or a rgb tuple
745+ returns a tuple of three or four floats from 0-1.
747746 """
748747 return self ._rgb
749748
@@ -771,9 +770,8 @@ def set_alpha(self, alpha):
771770 Set the alpha value used for blending - not supported on
772771 all backends
773772 """
774- if alpha is None :
775- alpha = 1.0
776- self ._alpha = alpha
773+ if alpha is not None :
774+ self ._alpha = alpha
777775
778776 def set_antialiased (self , b ):
779777 """
@@ -823,17 +821,19 @@ def set_dashes(self, dash_offset, dash_list):
823821 def set_foreground (self , fg , isRGB = False ):
824822 """
825823 Set the foreground color. fg can be a MATLAB format string, a
826- html hex color string, an rgb unit tuple, or a float between 0
824+ html hex color string, an rgb or rgba unit tuple, or a float between 0
827825 and 1. In the latter case, grayscale is used.
828826
829827 The :class:`GraphicsContextBase` converts colors to rgb
830- internally. If you know the color is rgb already, you can set
828+ internally. If you know the color is rgb or rgba already, you can set
831829 ``isRGB=True`` to avoid the performace hit of the conversion
832830 """
833831 if isRGB :
834832 self ._rgb = fg
835833 else :
836834 self ._rgb = colors .colorConverter .to_rgba (fg )
835+ if len (self ._rgb ) == 4 :
836+ self ._alpha = self ._rgb [3 ]
837837
838838 def set_graylevel (self , frac ):
839839 """
0 commit comments