Closed
Description
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)
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
Metadata
Metadata
Assignees
Labels
No labels