@@ -128,9 +128,10 @@ def __init__(self,
128128 # list of unbroadcast/scaled linewidths
129129 self ._us_lw = [0 ]
130130 self ._linewidths = [0 ]
131+ self ._is_filled = True # May be modified by set_facecolor().
131132
132- self .set_edgecolor (edgecolors )
133133 self .set_facecolor (facecolors )
134+ self .set_edgecolor (edgecolors )
134135 self .set_linewidth (linewidths )
135136 self .set_linestyle (linestyles )
136137 self .set_antialiased (antialiaseds )
@@ -492,14 +493,9 @@ def set_linewidth(self, lw):
492493 ACCEPTS: float or sequence of floats
493494 """
494495 if lw is None :
495- if (self ._edge_default or
496- mpl .rcParams ['_internal.classic_mode' ] or
497- not self ._is_filled ):
498- lw = mpl .rcParams ['patch.linewidth' ]
499- if lw is None :
500- lw = mpl .rcParams ['lines.linewidth' ]
501- else :
502- lw = 0
496+ lw = mpl .rcParams ['patch.linewidth' ]
497+ if lw is None :
498+ lw = mpl .rcParams ['lines.linewidth' ]
503499 # get the un-scaled/broadcast lw
504500 self ._us_lw = self ._get_value (lw )
505501
@@ -644,6 +640,20 @@ def set_color(self, c):
644640 self .set_facecolor (c )
645641 self .set_edgecolor (c )
646642
643+ def _set_facecolor (self , c ):
644+ if c is None :
645+ c = mpl .rcParams ['patch.facecolor' ]
646+
647+ self ._is_filled = True
648+ try :
649+ if c .lower () == 'none' :
650+ self ._is_filled = False
651+ except AttributeError :
652+ pass
653+ self ._facecolors = mcolors .to_rgba_array (c , self ._alpha )
654+ self .stale = True
655+
656+
647657 def set_facecolor (self , c ):
648658 """
649659 Set the facecolor(s) of the collection. *c* can be a
@@ -655,17 +665,9 @@ def set_facecolor(self, c):
655665
656666 ACCEPTS: matplotlib color spec or sequence of specs
657667 """
658- self ._is_filled = True
659- try :
660- if c .lower () == 'none' :
661- self ._is_filled = False
662- except AttributeError :
663- pass
664- if c is None :
665- c = mpl .rcParams ['patch.facecolor' ]
666- self ._facecolors_original = c
667- self ._facecolors = mcolors .to_rgba_array (c , self ._alpha )
668- self .stale = True
668+ self ._original_facecolor = c
669+ self ._set_facecolor (c )
670+
669671
670672 def set_facecolors (self , c ):
671673 """alias for set_facecolor"""
@@ -683,38 +685,45 @@ def get_edgecolor(self):
683685 return self ._edgecolors
684686 get_edgecolors = get_edgecolor
685687
686- def set_edgecolor (self , c ):
687- """
688- Set the edgecolor(s) of the collection. *c* can be a
689- matplotlib color spec (all patches have same color), or a
690- sequence of specs; if it is a sequence the patches will
691- cycle through the sequence.
692-
693- If *c* is 'face', the edge color will always be the same as
694- the face color. If it is 'none', the patch boundary will not
695- be drawn.
696-
697- ACCEPTS: matplotlib color spec or sequence of specs
698- """
688+ def _set_edgecolor (self , c ):
689+ if c is None :
690+ if (mpl .rcParams ['patch.force_edgecolor' ] or
691+ not self ._is_filled or self ._edge_default ):
692+ c = mpl .rcParams ['patch.edgecolor' ]
693+ else :
694+ c = 'none'
699695 self ._is_stroked = True
700696 try :
701697 if c .lower () == 'none' :
702698 self ._is_stroked = False
703699 except AttributeError :
704700 pass
701+
705702 try :
706- if c .lower () == 'face' :
703+ if c .lower () == 'face' : # Special case: lookup in "get" method.
707704 self ._edgecolors = 'face'
708- self ._edgecolors_original = 'face'
709705 return
710706 except AttributeError :
711707 pass
712- if c is None :
713- c = mpl .rcParams ['patch.edgecolor' ]
714- self ._edgecolors_original = c
715708 self ._edgecolors = mcolors .to_rgba_array (c , self ._alpha )
716709 self .stale = True
717710
711+ def set_edgecolor (self , c ):
712+ """
713+ Set the edgecolor(s) of the collection. *c* can be a
714+ matplotlib color spec (all patches have same color), or a
715+ sequence of specs; if it is a sequence the patches will
716+ cycle through the sequence.
717+
718+ If *c* is 'face', the edge color will always be the same as
719+ the face color. If it is 'none', the patch boundary will not
720+ be drawn.
721+
722+ ACCEPTS: matplotlib color spec or sequence of specs
723+ """
724+ self ._original_edgecolor = c
725+ self ._set_edgecolor (c )
726+
718727 def set_edgecolors (self , c ):
719728 """alias for set_edgecolor"""
720729 return self .set_edgecolor (c )
@@ -732,18 +741,8 @@ def set_alpha(self, alpha):
732741 except TypeError :
733742 raise TypeError ('alpha must be a float or None' )
734743 artist .Artist .set_alpha (self , alpha )
735- try :
736- self ._facecolors = mcolors .to_rgba_array (
737- self ._facecolors_original , self ._alpha )
738- except (AttributeError , TypeError , IndexError ):
739- pass
740- try :
741- if (not isinstance (self ._edgecolors_original , six .string_types )
742- or self ._edgecolors_original != str ('face' )):
743- self ._edgecolors = mcolors .to_rgba_array (
744- self ._edgecolors_original , self ._alpha )
745- except (AttributeError , TypeError , IndexError ):
746- pass
744+ self ._set_facecolor (self ._original_facecolor )
745+ self ._set_edgecolor (self ._original_edgecolor )
747746
748747 def get_linewidths (self ):
749748 return self ._linewidths
@@ -779,9 +778,9 @@ def update_from(self, other):
779778
780779 artist .Artist .update_from (self , other )
781780 self ._antialiaseds = other ._antialiaseds
782- self ._edgecolors_original = other ._edgecolors_original
781+ self ._original_edgecolor = other ._original_edgecolor
783782 self ._edgecolors = other ._edgecolors
784- self ._facecolors_original = other ._facecolors_original
783+ self ._original_facecolor = other ._original_facecolor
785784 self ._facecolors = other ._facecolors
786785 self ._linewidths = other ._linewidths
787786 self ._linestyles = other ._linestyles
0 commit comments