我已经使用 ggplot 很长时间了,并且在 R 中使用它非常舒服。我现在在 Python 上学,我很难理解这个错误。当我尝试使用 scale_color_manual 手动将颜色分配给我的名为“CellTypeOther”的变量,它的唯一值是 0/1,我不断收到以下错误:
NameError: name 'c' is not defined
这是我创建ggplot的代码:
from plotnine import *
plot = (
ggplot(Y_tsne,aes(x = 'X',y = 'Y'))
+ geom_point(aes(color = 'CellTypeOther'),alpha = 0.4,size = 2)
+ scale_color_manual(c("blue","red"))
)
没有最后一行,情节渲染得很好。有人对可能发生的事情有任何线索吗?我不能分享我的数据,因为它很敏感。
重要提示:我正在使用 plotnine Python 模块来利用 ggplot2。