Skip to content

Commit 2b7bcee

Browse files
lestevehayd
authored andcommitted
BUG: automatic color cycling when plotting Series without style or color argument
1 parent 1a976d8 commit 2b7bcee

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

pandas/tests/test_graphics.py

+12
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,18 @@ def test_time_series_plot_color_kwargs(self):
678678
line = ax.get_lines()[0]
679679
self.assert_(line.get_color() == 'green')
680680

681+
@slow
682+
def test_time_series_plot_color_with_empty_kwargs(self):
683+
import matplotlib.pyplot as plt
684+
685+
plt.close('all')
686+
for i in range(3):
687+
ax = Series(np.arange(12) + 1, index=date_range(
688+
'1/1/2000', periods=12)).plot()
689+
690+
line_colors = [ l.get_color() for l in ax.get_lines() ]
691+
self.assert_(line_colors == ['b', 'g', 'r'])
692+
681693
@slow
682694
def test_grouped_hist(self):
683695
import matplotlib.pyplot as plt

pandas/tools/plotting.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1122,13 +1122,12 @@ def _get_colors(self):
11221122
cycle = plt.rcParams.get('axes.color_cycle', list('bgrcmyk'))
11231123
if isinstance(cycle, basestring):
11241124
cycle = list(cycle)
1125-
has_colors = 'color' in self.kwds
11261125
colors = self.kwds.get('color', cycle)
11271126
return colors
11281127

11291128
def _maybe_add_color(self, colors, kwds, style, i):
1130-
kwds.pop('color', None)
1131-
if style is None or re.match('[a-z]+', style) is None:
1129+
has_color = 'color' in kwds
1130+
if has_color and (style is None or re.match('[a-z]+', style) is None):
11321131
kwds['color'] = colors[i % len(colors)]
11331132

11341133
def _make_plot(self):

0 commit comments

Comments
 (0)