Skip to content

Commit d5e4d0a

Browse files
committed
remove call to self._get_colors() from inside _maybe_add_color() - not efficient
1 parent 75590c4 commit d5e4d0a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pandas/tools/plotting.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -876,8 +876,7 @@ def _get_colors(self):
876876
colors = self.kwds.pop('colors', cycle)
877877
return has_colors, colors
878878

879-
def _maybe_add_color(self, kwds, style, i):
880-
has_colors, colors = self._get_colors()
879+
def _maybe_add_color(self, has_colors, colors, kwds, style, i):
881880
if (not has_colors and
882881
(style is None or re.match('[a-z]+', style) is None)
883882
and 'color' not in kwds):
@@ -894,12 +893,13 @@ def _make_plot(self):
894893
x = self._get_xticks(convert_period=True)
895894

896895
plotf = self._get_plot_function()
896+
has_colors, colors = self._get_colors()
897897

898898
for i, (label, y) in enumerate(self._iter_data()):
899899
ax = self._get_ax(i)
900900
style = self._get_style(i, label)
901901
kwds = self.kwds.copy()
902-
self._maybe_add_color(kwds, style, i)
902+
self._maybe_add_color(has_colors, colors, kwds, style, i)
903903

904904
label = _stringify(label)
905905

@@ -943,7 +943,7 @@ def to_leg_label(label, i):
943943
style = self.style or ''
944944
label = com._stringify(self.label)
945945
kwds = kwargs.copy()
946-
self._maybe_add_color(kwds, style, 0)
946+
self._maybe_add_color(has_colors, colors, kwds, style, 0)
947947

948948
newlines = tsplot(data, plotf, ax=ax, label=label, style=self.style,
949949
**kwds)
@@ -958,7 +958,7 @@ def to_leg_label(label, i):
958958
style = self._get_style(i, col)
959959
kwds = kwargs.copy()
960960

961-
self._maybe_add_color(kwds, style, i)
961+
self._maybe_add_color(has_colors, colors, kwds, style, i)
962962

963963
newlines = tsplot(data[col], plotf, ax=ax, label=label,
964964
style=style, **kwds)

0 commit comments

Comments
 (0)