Skip to content

Commit 33bb84b

Browse files
committed
BUG: don't clobber color keyword in Series.plot, close #1890
1 parent a83e691 commit 33bb84b

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

RELEASE.rst

+1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ pandas 0.9.0
148148
- Fix resampling error with intraday times and anchored target time (like
149149
AS-DEC) (#1772)
150150
- Fix .ix indexing bugs with mixed-integer indexes (#1799)
151+
- Respect passed color keyword argument in Series.plot (#1890)
151152

152153
pandas 0.8.1
153154
============

pandas/tests/test_graphics.py

+10
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,16 @@ def test_boxplot(self):
479479
_check_plot_works(grouped.boxplot)
480480
_check_plot_works(grouped.boxplot, subplots=False)
481481

482+
@slow
483+
def test_series_plot_color_kwargs(self):
484+
# #1890
485+
import matplotlib.pyplot as plt
486+
487+
plt.close('all')
488+
ax = Series(np.arange(12) + 1).plot(color='green')
489+
line = ax.get_lines()[0]
490+
self.assert_(line.get_color() == 'green')
491+
482492
PNG_PATH = 'tmp.png'
483493

484494
def _check_plot_works(f, *args, **kwargs):

pandas/tools/plotting.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,8 @@ def _make_plot(self):
889889
has_colors, colors = self._get_colors()
890890
def _maybe_add_color(kwargs, style, i):
891891
if (not has_colors and
892-
(style is None or re.match('[a-z]+', style) is None)):
892+
(style is None or re.match('[a-z]+', style) is None)
893+
and 'color' not in kwargs):
893894
kwargs['color'] = colors[i % len(colors)]
894895

895896
plotf = self._get_plot_function()

0 commit comments

Comments
 (0)