如何在Python中使用scale_color_manual?

问题描述

我已经使用ggplot很长时间了,并且在R中使用它非常自在。我现在正在学校里用Python工作,而我在理解这个错误方面最艰难。当我尝试使用scale_color_manual手动将颜色分配给具有唯一值0/1的名为“ CellTypeOther”的变量时,我不断收到以下错误

            Start_date  End_date
Employee_ID     
SNC1289037  2020-01-01  2199-12-31
SNC2289038  2020-01-01  2199-12-31
SNC4589038  2020-01-01  2020-03-30

这是我创建ggplot的代码

NameError: name 'c' is not defined

该图在没有最后一行的情况下呈现良好。有人对可能发生的事情有任何线索吗?我无法共享我的数据,因为它很敏感。

重要说明:我正在使用plotnine python模块来利用ggplot2。

解决方法

您应该在Python中使用[]而不是c()

enter image description here