Skip to content

[Bug]: Pandas plot does not accept Columns for color keyword #21795

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
mosc9575 opened this issue Nov 29, 2021 · 6 comments
Closed

[Bug]: Pandas plot does not accept Columns for color keyword #21795

mosc9575 opened this issue Nov 29, 2021 · 6 comments

Comments

@mosc9575
Copy link

mosc9575 commented Nov 29, 2021

Bug summary

I tried to plot a scatterplot with different groups, with one color for each group. I thought is is enought to pass the name of the column to the color-keyword, but this throws an error:

ValueError: 'c' argument must be a color, a sequence of colors, or a sequence of numbers, not ['color'].

Code for reproduction

import pandas as pd

df = pd.DataFrame({
 'A': {1: 6, 2: 2, 3: 1, 4: 8, 5: 6},
 'B': {1: 2, 2: 10, 3: 3, 4: 1, 5: 1},
 'pos': {1: 1, 2: 2, 3: 4, 4: 1, 5: 1},
 'color': {1: 'red', 2: 'blue', 3: 'green', 4: 'red', 5: 'red'}
})

df >>>
   A   B  color
1  6   2    red
2  2  10   blue
3  1   3  green
4  8   1    red
5  6   1    red


# s.plot(x='A', y='B', kind='scatter', color=s['color'].values)
df.plot(x='A', y='B', kind='scatter', color='color')

Actual outcome

Right now I get an error:
ValueError: 'c' argument must be a color, a sequence of colors, or a sequence of numbers, not ['color'].

Expected outcome

I expect this figure, which was generated using the commented line

s.plot(x='A', y='B', kind='scatter', color=s['color'].values)

grafik

Additional information

No response

Operating system

Linux-5.10.0-8-amd64-x86_64-with-glibc2.31

Matplotlib Version

3.4.3

Matplotlib Backend

module://matplotlib_inline.backend_inline

Python version

3.9.7

Jupyter version

6.4.4

Installation

conda

@jklymak
Copy link
Member

jklymak commented Nov 29, 2021

We don't maintain df.plot, so please take up with pandas.pydata.org. Thanks!

@jklymak jklymak closed this as completed Nov 29, 2021
@mosc9575
Copy link
Author

mosc9575 commented Nov 29, 2021

@jklymak Thank you for you response. You are rigth, this is the wrong Repo.

@jklymak
Copy link
Member

jklymak commented Nov 29, 2021

The issue could still be on our side, but if so, then please isolate it to work without pandas....

@mosc9575
Copy link
Author

mosc9575 commented Dec 12, 2021

@jklymak I came back to this issue and I found out that scatter has the keyword c instead of color which is used in bar. This seems like an inconsistency and not very intuativ (to mee).

Since pandas trys to pass the keywords without any changes, the c keyword can be found in both libraries.

Is this a bug and should this issue be reopend?

@jklymak
Copy link
Member

jklymak commented Dec 12, 2021

No this has been this way for many years, and changing has been discussed and rejected in the past.

@mosc9575
Copy link
Author

Thanks for your response. In this case this is closed for me, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants