diff --git a/RELEASE.rst b/RELEASE.rst index 4c8d99903f839..5c3d210fccf6f 100644 --- a/RELEASE.rst +++ b/RELEASE.rst @@ -76,6 +76,8 @@ pandas 0.11.0 (e.g. np.array(datetime(2001,1,1,0,0))), w/o dtype being passed - 0-dim ndarrays with a passed dtype are handled correctly (e.g. np.array(0.,dtype='float32')) + - fix automatic color cycling when plotting consecutive timeseries + without color arguments (GH2816_) .. _GH622: https://github.com/pydata/pandas/issues/622 .. _GH797: https://github.com/pydata/pandas/issues/797 @@ -83,6 +85,7 @@ pandas 0.11.0 .. _GH2793: https://github.com/pydata/pandas/issues/2793 .. _GH2751: https://github.com/pydata/pandas/issues/2751 .. _GH2747: https://github.com/pydata/pandas/issues/2747 +.. _GH2816: https://github.com/pydata/pandas/issues/2816 pandas 0.10.1 ============= diff --git a/pandas/tests/test_graphics.py b/pandas/tests/test_graphics.py index e542fd423ff9b..d851f527f21ab 100644 --- a/pandas/tests/test_graphics.py +++ b/pandas/tests/test_graphics.py @@ -675,6 +675,18 @@ def test_time_series_plot_color_kwargs(self): line = ax.get_lines()[0] self.assert_(line.get_color() == 'green') + @slow + def test_time_series_plot_color_with_empty_kwargs(self): + import matplotlib.pyplot as plt + + plt.close('all') + for i in range(3): + ax = Series(np.arange(12) + 1, index=date_range( + '1/1/2000', periods=12)).plot() + + line_colors = [ l.get_color() for l in ax.get_lines() ] + self.assert_(line_colors == ['b', 'g', 'r']) + @slow def test_grouped_hist(self): import matplotlib.pyplot as plt diff --git a/pandas/tools/plotting.py b/pandas/tools/plotting.py index 246f05ae8d542..7df52ed2e2f6b 100644 --- a/pandas/tools/plotting.py +++ b/pandas/tools/plotting.py @@ -748,6 +748,8 @@ def _maybe_right_yaxis(self, ax): if (sec_true or has_sec) and not hasattr(ax, 'right_ax'): orig_ax, new_ax = ax, ax.twinx() + new_ax._get_lines.color_cycle = orig_ax._get_lines.color_cycle + orig_ax.right_ax, new_ax.left_ax = new_ax, orig_ax if len(orig_ax.get_lines()) == 0: # no data on left y @@ -1063,13 +1065,12 @@ def _get_colors(self): cycle = plt.rcParams.get('axes.color_cycle', list('bgrcmyk')) if isinstance(cycle, basestring): cycle = list(cycle) - has_colors = 'color' in self.kwds colors = self.kwds.get('color', cycle) return colors def _maybe_add_color(self, colors, kwds, style, i): - kwds.pop('color', None) - if style is None or re.match('[a-z]+', style) is None: + has_color = 'color' in kwds + if has_color and (style is None or re.match('[a-z]+', style) is None): kwds['color'] = colors[i % len(colors)] def _make_plot(self): @@ -2077,6 +2078,8 @@ def on_right(i): if on_right(0): orig_ax = ax0 ax0 = ax0.twinx() + ax0._get_lines.color_cycle = orig_ax._get_lines.color_cycle + orig_ax.get_yaxis().set_visible(False) orig_ax.right_ax = ax0 ax0.left_ax = orig_ax @@ -2094,6 +2097,8 @@ def on_right(i): if on_right(i): orig_ax = ax ax = ax.twinx() + ax._get_lines.color_cycle = orig_ax._get_lines.color_cycle + orig_ax.get_yaxis().set_visible(False) axarr[i] = ax