ValueError: Invalid RGBA argument: 'o'

房东的猫 提交于 2019-12-10 17:35:59

问题


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  

...


回答1:


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)


来源:https://stackoverflow.com/questions/45739673/valueerror-invalid-rgba-argument-o

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!