Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ValueError: Invalid RGBA argument: 'o'

Tags:

python

scatter

I am trying to draw a scatter plot in Python with color code stored in 'color' column of dataframe. And I get invalid RGBA argument error.

Here's my code and data:

df.plot.scatter(x='x', y='y', c='color')  

      id         x     type     color     y
0    109       570.4       ha     r     500.8
1    110       632.4       ha     r     567.2
2    111       399.4       of     b     487.2
3    112       250.2       of     b     444.4  

...

like image 370
ejshin1 Avatar asked Jan 29 '23 18:01

ejshin1


1 Answers

I just solved it by this code.

col = df['type'].map({'ha':'r', 'of':'b', 'cu':'y'})
df.plot.scatter(x='x', y='y', c=col)
like image 102
ejshin1 Avatar answered Feb 02 '23 10:02

ejshin1