@@ -793,7 +793,7 @@ def _get_style(self, i, col_name):
793
793
else :
794
794
style = self .style
795
795
796
- return style
796
+ return style or None
797
797
798
798
class KdePlot (MPLPlot ):
799
799
def __init__ (self , data , ** kwargs ):
@@ -813,12 +813,19 @@ def _make_plot(self):
813
813
ind = np .linspace (min (y ) - 0.5 * sample_range ,
814
814
max (y ) + 0.5 * sample_range , 1000 )
815
815
ax .set_ylabel ("Density" )
816
- plotf (ax , ind , gkde .evaluate (ind ), style , label = label , ** self .kwds )
816
+
817
+ y = gkde .evaluate (ind )
818
+ kwds = self .kwds .copy ()
819
+ kwds ['label' ] = label
820
+ if style is None :
821
+ args = (ax , ind , y )
822
+ else :
823
+ args = (ax , ind , y , style )
824
+
825
+ plotf (* args , ** kwds )
817
826
ax .grid (self .grid )
818
827
819
828
def _post_plot_logic (self ):
820
- df = self .data
821
-
822
829
if self .subplots and self .legend :
823
830
for ax in self .axes :
824
831
ax .legend (loc = 'best' )
@@ -871,19 +878,25 @@ def _make_plot(self):
871
878
import matplotlib .pyplot as plt
872
879
cycle = '' .join (plt .rcParams .get ('axes.color_cycle' ,
873
880
list ('bgrcmyk' )))
881
+ has_colors = 'colors' in self .kwds
874
882
colors = self .kwds .pop ('colors' , cycle )
875
883
lines = []
876
884
labels = []
877
885
x = self ._get_xticks (convert_period = True )
878
886
887
+ def _maybe_add_color (kwargs , style , i ):
888
+ if (has_colors and
889
+ (style is None or re .match ('[a-z]+' , style ) is None )):
890
+ kwargs ['color' ] = colors [i % len (colors )]
891
+
879
892
plotf = self ._get_plot_function ()
880
893
881
894
for i , (label , y ) in enumerate (self ._iter_data ()):
882
895
ax = self ._get_ax (i )
883
896
style = self ._get_style (i , label )
884
897
kwds = self .kwds .copy ()
885
- if re . match ( '[a-z]+' , style ) is None :
886
- kwds [ 'color' ] = colors [ i % len ( colors )]
898
+
899
+ _maybe_add_color ( kwds , style , i )
887
900
888
901
label = _stringify (label )
889
902
@@ -892,7 +905,13 @@ def _make_plot(self):
892
905
y = np .ma .array (y )
893
906
y = np .ma .masked_where (mask , y )
894
907
895
- newline = plotf (ax , x , y , style , label = label , ** kwds )[0 ]
908
+ kwds ['label' ] = label
909
+ if style is None :
910
+ args = (ax , x , y )
911
+ else :
912
+ args = (ax , x , y , style )
913
+
914
+ newline = plotf (* args , ** kwds )[0 ]
896
915
lines .append (newline )
897
916
leg_label = label
898
917
if self .mark_right and self .on_right (i ):
@@ -907,12 +926,19 @@ def _make_ts_plot(self, data, **kwargs):
907
926
import matplotlib .pyplot as plt
908
927
kwargs = kwargs .copy ()
909
928
cycle = '' .join (plt .rcParams .get ('axes.color_cycle' , list ('bgrcmyk' )))
929
+
930
+ has_colors = 'colors' in kwargs
910
931
colors = kwargs .pop ('colors' , '' .join (cycle ))
911
932
912
933
plotf = self ._get_plot_function ()
913
934
lines = []
914
935
labels = []
915
936
937
+ def _maybe_add_color (kwargs , style , i ):
938
+ if (has_colors and
939
+ (style is None or re .match ('[a-z]+' , style ) is None )):
940
+ kwargs ['color' ] = colors [i % len (colors )]
941
+
916
942
def to_leg_label (label , i ):
917
943
if self .mark_right and self .on_right (i ):
918
944
return label + ' (right)'
@@ -922,8 +948,8 @@ def to_leg_label(label, i):
922
948
ax = self ._get_ax (0 ) #self.axes[0]
923
949
style = self .style or ''
924
950
label = com ._stringify (self .label )
925
- if re . match ( '[a-z]+' , style ) is None :
926
- kwargs [ 'color' ] = colors [ 0 ]
951
+
952
+ _maybe_add_color ( kwargs , style , 0 )
927
953
928
954
newlines = tsplot (data , plotf , ax = ax , label = label , style = self .style ,
929
955
** kwargs )
@@ -937,8 +963,8 @@ def to_leg_label(label, i):
937
963
ax = self ._get_ax (i )
938
964
style = self ._get_style (i , col )
939
965
kwds = kwargs .copy ()
940
- if re . match ( '[a-z]+' , style ) is None :
941
- kwds [ 'color' ] = colors [ i % len ( colors )]
966
+
967
+ _maybe_add_color ( kwargs , style , i )
942
968
943
969
newlines = tsplot (data [col ], plotf , ax = ax , label = label ,
944
970
style = style , ** kwds )
0 commit comments