Skip to content

Plotting methods modify color arrays in place #12039

Closed
@mwaskom

Description

@mwaskom

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 :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions