@@ -876,6 +876,12 @@ def _get_colors(self):
876
876
colors = self .kwds .pop ('colors' , cycle )
877
877
return has_colors , colors
878
878
879
+ def _maybe_add_color (self , has_colors , colors , kwds , style , i ):
880
+ if (not has_colors and
881
+ (style is None or re .match ('[a-z]+' , style ) is None )
882
+ and 'color' not in kwds ):
883
+ kwds ['color' ] = colors [i % len (colors )]
884
+
879
885
def _make_plot (self ):
880
886
# this is slightly deceptive
881
887
if self .use_index and self ._use_dynamic_x ():
@@ -886,21 +892,14 @@ def _make_plot(self):
886
892
labels = []
887
893
x = self ._get_xticks (convert_period = True )
888
894
889
- has_colors , colors = self ._get_colors ()
890
- def _maybe_add_color (kwargs , style , i ):
891
- if (not has_colors and
892
- (style is None or re .match ('[a-z]+' , style ) is None )
893
- and 'color' not in kwargs ):
894
- kwargs ['color' ] = colors [i % len (colors )]
895
-
896
895
plotf = self ._get_plot_function ()
896
+ has_colors , colors = self ._get_colors ()
897
897
898
898
for i , (label , y ) in enumerate (self ._iter_data ()):
899
899
ax = self ._get_ax (i )
900
900
style = self ._get_style (i , label )
901
901
kwds = self .kwds .copy ()
902
-
903
- _maybe_add_color (kwds , style , i )
902
+ self ._maybe_add_color (has_colors , colors , kwds , style , i )
904
903
905
904
label = com .pprint_thing (label ).encode ('utf-8' )
906
905
@@ -934,11 +933,6 @@ def _make_ts_plot(self, data, **kwargs):
934
933
lines = []
935
934
labels = []
936
935
937
- def _maybe_add_color (kwargs , style , i ):
938
- if (not has_colors and
939
- (style is None or re .match ('[a-z]+' , style ) is None )):
940
- kwargs ['color' ] = colors [i % len (colors )]
941
-
942
936
def to_leg_label (label , i ):
943
937
if self .mark_right and self .on_right (i ):
944
938
return label + ' (right)'
@@ -949,7 +943,7 @@ def to_leg_label(label, i):
949
943
style = self .style or ''
950
944
label = com .pprint_thing (self .label )
951
945
kwds = kwargs .copy ()
952
- _maybe_add_color (kwds , style , 0 )
946
+ self . _maybe_add_color (has_colors , colors , kwds , style , 0 )
953
947
954
948
newlines = tsplot (data , plotf , ax = ax , label = label , style = self .style ,
955
949
** kwds )
@@ -964,7 +958,7 @@ def to_leg_label(label, i):
964
958
style = self ._get_style (i , col )
965
959
kwds = kwargs .copy ()
966
960
967
- _maybe_add_color (kwds , style , i )
961
+ self . _maybe_add_color (has_colors , colors , kwds , style , i )
968
962
969
963
newlines = tsplot (data [col ], plotf , ax = ax , label = label ,
970
964
style = style , ** kwds )
0 commit comments