@@ -130,9 +130,10 @@ def __init__(self,
130130 # list of unbroadcast/scaled linewidths
131131 self ._us_lw = [0 ]
132132 self ._linewidths = [0 ]
133+ self ._is_filled = True # May be modified by set_facecolor().
133134
134- self .set_edgecolor (edgecolors )
135135 self .set_facecolor (facecolors )
136+ self .set_edgecolor (edgecolors )
136137 self .set_linewidth (linewidths )
137138 self .set_linestyle (linestyles )
138139 self .set_antialiased (antialiaseds )
@@ -494,14 +495,9 @@ def set_linewidth(self, lw):
494495 ACCEPTS: float or sequence of floats
495496 """
496497 if lw is None :
497- if (self ._edge_default or
498- mpl .rcParams ['_internal.classic_mode' ] or
499- not self ._is_filled ):
500- lw = mpl .rcParams ['patch.linewidth' ]
501- if lw is None :
502- lw = mpl .rcParams ['lines.linewidth' ]
503- else :
504- lw = 0
498+ lw = mpl .rcParams ['patch.linewidth' ]
499+ if lw is None :
500+ lw = mpl .rcParams ['lines.linewidth' ]
505501 # get the un-scaled/broadcast lw
506502 self ._us_lw = self ._get_value (lw )
507503
@@ -646,6 +642,20 @@ def set_color(self, c):
646642 self .set_facecolor (c )
647643 self .set_edgecolor (c )
648644
645+ def _set_facecolor (self , c ):
646+ if c is None :
647+ c = mpl .rcParams ['patch.facecolor' ]
648+
649+ self ._is_filled = True
650+ try :
651+ if c .lower () == 'none' :
652+ self ._is_filled = False
653+ except AttributeError :
654+ pass
655+ self ._facecolors = mcolors .to_rgba_array (c , self ._alpha )
656+ self .stale = True
657+
658+
649659 def set_facecolor (self , c ):
650660 """
651661 Set the facecolor(s) of the collection. *c* can be a
@@ -657,17 +667,9 @@ def set_facecolor(self, c):
657667
658668 ACCEPTS: matplotlib color spec or sequence of specs
659669 """
660- self ._is_filled = True
661- try :
662- if c .lower () == 'none' :
663- self ._is_filled = False
664- except AttributeError :
665- pass
666- if c is None :
667- c = mpl .rcParams ['patch.facecolor' ]
668- self ._facecolors_original = c
669- self ._facecolors = mcolors .to_rgba_array (c , self ._alpha )
670- self .stale = True
670+ self ._original_facecolor = c
671+ self ._set_facecolor (c )
672+
671673
672674 def set_facecolors (self , c ):
673675 """alias for set_facecolor"""
@@ -685,38 +687,45 @@ def get_edgecolor(self):
685687 return self ._edgecolors
686688 get_edgecolors = get_edgecolor
687689
688- def set_edgecolor (self , c ):
689- """
690- Set the edgecolor(s) of the collection. *c* can be a
691- matplotlib color spec (all patches have same color), or a
692- sequence of specs; if it is a sequence the patches will
693- cycle through the sequence.
694-
695- If *c* is 'face', the edge color will always be the same as
696- the face color. If it is 'none', the patch boundary will not
697- be drawn.
698-
699- ACCEPTS: matplotlib color spec or sequence of specs
700- """
690+ def _set_edgecolor (self , c ):
691+ if c is None :
692+ if (mpl .rcParams ['patch.force_edgecolor' ] or
693+ not self ._is_filled or self ._edge_default ):
694+ c = mpl .rcParams ['patch.edgecolor' ]
695+ else :
696+ c = 'none'
701697 self ._is_stroked = True
702698 try :
703699 if c .lower () == 'none' :
704700 self ._is_stroked = False
705701 except AttributeError :
706702 pass
703+
707704 try :
708- if c .lower () == 'face' :
705+ if c .lower () == 'face' : # Special case: lookup in "get" method.
709706 self ._edgecolors = 'face'
710- self ._edgecolors_original = 'face'
711707 return
712708 except AttributeError :
713709 pass
714- if c is None :
715- c = mpl .rcParams ['patch.edgecolor' ]
716- self ._edgecolors_original = c
717710 self ._edgecolors = mcolors .to_rgba_array (c , self ._alpha )
718711 self .stale = True
719712
713+ def set_edgecolor (self , c ):
714+ """
715+ Set the edgecolor(s) of the collection. *c* can be a
716+ matplotlib color spec (all patches have same color), or a
717+ sequence of specs; if it is a sequence the patches will
718+ cycle through the sequence.
719+
720+ If *c* is 'face', the edge color will always be the same as
721+ the face color. If it is 'none', the patch boundary will not
722+ be drawn.
723+
724+ ACCEPTS: matplotlib color spec or sequence of specs
725+ """
726+ self ._original_edgecolor = c
727+ self ._set_edgecolor (c )
728+
720729 def set_edgecolors (self , c ):
721730 """alias for set_edgecolor"""
722731 return self .set_edgecolor (c )
@@ -734,18 +743,8 @@ def set_alpha(self, alpha):
734743 except TypeError :
735744 raise TypeError ('alpha must be a float or None' )
736745 artist .Artist .set_alpha (self , alpha )
737- try :
738- self ._facecolors = mcolors .to_rgba_array (
739- self ._facecolors_original , self ._alpha )
740- except (AttributeError , TypeError , IndexError ):
741- pass
742- try :
743- if (not isinstance (self ._edgecolors_original , six .string_types )
744- or self ._edgecolors_original != str ('face' )):
745- self ._edgecolors = mcolors .to_rgba_array (
746- self ._edgecolors_original , self ._alpha )
747- except (AttributeError , TypeError , IndexError ):
748- pass
746+ self ._set_facecolor (self ._original_facecolor )
747+ self ._set_edgecolor (self ._original_edgecolor )
749748
750749 def get_linewidths (self ):
751750 return self ._linewidths
@@ -781,9 +780,9 @@ def update_from(self, other):
781780
782781 artist .Artist .update_from (self , other )
783782 self ._antialiaseds = other ._antialiaseds
784- self ._edgecolors_original = other ._edgecolors_original
783+ self ._original_edgecolor = other ._original_edgecolor
785784 self ._edgecolors = other ._edgecolors
786- self ._facecolors_original = other ._facecolors_original
785+ self ._original_facecolor = other ._original_facecolor
787786 self ._facecolors = other ._facecolors
788787 self ._linewidths = other ._linewidths
789788 self ._linestyles = other ._linestyles
0 commit comments