ValueError: invalid argument RGBA: 'o'

I am trying to draw a scatter chart in Python with color code stored in the color column in a dataframe. And I get an invalid RGBA argument error.

Here is 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  

...

+4
source share
1 answer

I just solved it with this code.

col = df['type'].map({'ha':'r', 'of':'b', 'cu':'y'})
df.plot.scatter(x='x', y='y', c=col)
+6
source

Source: https://habr.com/ru/post/1683909/


All Articles