Skip to content

BUG: .plot modifing colors input #12040

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/source/whatsnew/v0.18.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,8 @@ Bug Fixes
- Bug in ``DataFrame`` when masking an empty ``DataFrame`` (:issue:`11859`)



- Bug in ``.plot`` potentially modifying the ``colors`` input when the number
of columns didn't match the number of series provided (:issue:`12039`).



Expand Down
6 changes: 6 additions & 0 deletions pandas/tests/test_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2717,6 +2717,12 @@ def test_line_colors(self):
# Forced show plot
_check_plot_works(df.plot, color=custom_colors)

@slow
def test_dont_modify_colors(self):
colors = ['r', 'g', 'b']
pd.DataFrame(np.random.rand(10, 2)).plot(color=colors)
self.assertEqual(len(colors), 3)

@slow
def test_line_colors_and_styles_subplots(self):
# GH 9894
Expand Down
2 changes: 1 addition & 1 deletion pandas/tools/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def _get_standard_colors(num_colors=None, colormap=None, color_type='default',
if colormap is not None:
warnings.warn("'color' and 'colormap' cannot be used "
"simultaneously. Using 'color'")
colors = color
colors = list(color) if com.is_list_like(color) else color
else:
if color_type == 'default':
# need to call list() on the result to copy so we don't
Expand Down