【问题标题】:adding legend when plotting with rpy2使用 rpy2 绘图时添加图例
【发布时间】:2012-11-17 10:49:35
【问题描述】:

我正在尝试使用以下命令绘制 ECDF 但是当我运行脚本时,我得到了这个错误

1: In rect(left, top, r, b, angle = angle, density = density, ...) :
  supplied color is not numeric nor character
2: In rect(left, top, r, b, angle = angle, density = density, ...) :
  supplied color is not numeric nor character

我的代码是:

import rpy2.robjects as robj
ce=robj.FloatVector(range(1,100,1))
le=robj.FloatVector(range(5,500,2))
label="score"
l1="a"
l2="b"

robj.r["plot.ecdf"](ce,main="",verticals=True,pch=46,col="grey",xlab=label)
robj.r["plot.ecdf"](le,verticals=True,pch=46,col="red",add=True)
robj.r.legend("topleft",legend=[l1,l2],fill=["grey","red"])

有什么想法吗?

【问题讨论】:

  • 此代码将很快失败,因为它缺少celabellestatistic 的定义。你能把它修改成reproducible吗?谢谢!

标签: python legend rpy2


【解决方案1】:

更正您对legend 的调用中的Python 列表。例如,fill 应该是 fill=robj.StrVector(["grey", "red"])

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多