Skip to content

Commit 184f2db

Browse files
committed
Merge pull request #3207 from hayd/GH2836-resolve-merge-conflict
Gh2836 resolve merge conflict
2 parents 1a976d8 + 2dd5f7b commit 184f2db

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

RELEASE.rst

+5
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ pandas 0.11.0
246246
- Add comparison operators to Period object (GH2781_)
247247
- Fix bug when concatenating two Series into a DataFrame when they have the
248248
same name (GH2797_)
249+
- fix automatic color cycling when plotting consecutive timeseries
250+
without color arguments (GH2816_)
249251

250252
.. _GH622: https://github.com/pydata/pandas/issues/622
251253
.. _GH797: https://github.com/pydata/pandas/issues/797
@@ -329,6 +331,9 @@ pandas 0.11.0
329331
.. _GH3178: https://github.com/pydata/pandas/issues/3178
330332
.. _GH3179: https://github.com/pydata/pandas/issues/3179
331333
.. _GH3189: https://github.com/pydata/pandas/issues/3189
334+
.. _GH2751: https://github.com/pydata/pandas/issues/2751
335+
.. _GH2747: https://github.com/pydata/pandas/issues/2747
336+
.. _GH2816: https://github.com/pydata/pandas/issues/2816
332337

333338
pandas 0.10.1
334339
=============

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

+8-3
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,8 @@ def _maybe_right_yaxis(self, ax):
807807

808808
if (sec_true or has_sec) and not hasattr(ax, 'right_ax'):
809809
orig_ax, new_ax = ax, ax.twinx()
810+
new_ax._get_lines.color_cycle = orig_ax._get_lines.color_cycle
811+
810812
orig_ax.right_ax, new_ax.left_ax = new_ax, orig_ax
811813

812814
if len(orig_ax.get_lines()) == 0: # no data on left y
@@ -1122,13 +1124,12 @@ def _get_colors(self):
11221124
cycle = plt.rcParams.get('axes.color_cycle', list('bgrcmyk'))
11231125
if isinstance(cycle, basestring):
11241126
cycle = list(cycle)
1125-
has_colors = 'color' in self.kwds
11261127
colors = self.kwds.get('color', cycle)
11271128
return colors
11281129

11291130
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:
1131+
has_color = 'color' in kwds
1132+
if has_color and (style is None or re.match('[a-z]+', style) is None):
11321133
kwds['color'] = colors[i % len(colors)]
11331134

11341135
def _make_plot(self):
@@ -2147,6 +2148,8 @@ def on_right(i):
21472148
if on_right(0):
21482149
orig_ax = ax0
21492150
ax0 = ax0.twinx()
2151+
ax0._get_lines.color_cycle = orig_ax._get_lines.color_cycle
2152+
21502153
orig_ax.get_yaxis().set_visible(False)
21512154
orig_ax.right_ax = ax0
21522155
ax0.left_ax = orig_ax
@@ -2164,6 +2167,8 @@ def on_right(i):
21642167
if on_right(i):
21652168
orig_ax = ax
21662169
ax = ax.twinx()
2170+
ax._get_lines.color_cycle = orig_ax._get_lines.color_cycle
2171+
21672172
orig_ax.get_yaxis().set_visible(False)
21682173
axarr[i] = ax
21692174

0 commit comments

Comments
 (0)