Skip to content

Plotting methods modify color arrays in place #12039

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

Closed
mwaskom opened this issue Jan 14, 2016 · 0 comments
Closed

Plotting methods modify color arrays in place #12039

mwaskom opened this issue Jan 14, 2016 · 0 comments
Labels
Milestone

Comments

@mwaskom
Copy link
Contributor

mwaskom commented Jan 14, 2016

Ran into a weird issue where pandas plotting was changing values in color arrays I was passing to it.

Here is a simple example (Pandas 0.17.1; Python 2.7; OSX):

colors = sns.color_palette("Blues", 3)
print len(colors)
pd.DataFrame(np.random.rand(10, 2)).plot(color=colors)
print len(colors)

outputs:

3
5

I've seen various other kinds of changes, including sometimes changing the values but not the length of the color array. A particularly nasty one was where I had taken some actual data and passed it through a matplotlib norm and colormap, and the modifications made their way all the way back up to my data.

I assume this can easily be handled by copying the color array, but I'm not sure.

Sorry if this has been reported...I checked recent issues and didn't see anything, but there are a lot :)

@TomAugspurger TomAugspurger added the Visualization plotting label Jan 14, 2016
@TomAugspurger TomAugspurger added this to the 0.18.0 milestone Jan 14, 2016
TomAugspurger added a commit to TomAugspurger/pandas that referenced this issue Jan 15, 2016
Closes pandas-dev#12039

Just added a defensive copy in `_get_standard_colors`
on list-likes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants