python - 使用 rpy2 更改 ggplot2 中的图例

标签 python ggplot2 rpy2

我正在尝试使用 rpy2 在 ggplot2 中自定义图例。我注意到 ggplot2 到 rpy2 没有 scale_shape_discrete 以及 http://www.cookbook-r.com/Graphs/Legends_(ggplot2)/ 中显示的其他方法根据需要定制图例。

from rpy2.robjects.lib import ggplot2
# not present
ggplot2.scale_shape_discrete 

通过 rpy2 重命名/自定义 ggplot2 中离散图例的正确方法是什么?这些方法可以访问吗?

最佳答案

它不见了。你可以

1) 在 rpy2 的 bitbucket 页面上报告问题。

2)将其定义为:

from rpy2.robjects.lib import ggplot2
class ScaleShapeDiscrete(ggplot2.Scale):
    _constructor = ggplot2.ggplot2_env['scale_shape_discrete']
scale_shape_discrete = ScaleShapeDiscrete.new

关于python - 使用 rpy2 更改 ggplot2 中的图例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15480031/

相关文章:

python - 使用 rpy2 将 .R 文件采购到 python 中的问题

python - django 中的部分反向 url 查找

python - 第二次 python 执行失败

Python日志记录: logging config file with changing save location

从 ggplot 中删除 y 标签

r - 如何向 Facet_Grid strip 标签添加希腊字母?

r - 将 R 代码与 Web 服务器集成

python - 类型错误 : expected string or bytes-like object and works on server but not on PC

R:ggplot 和 plotly 轴边距不会改变

r - 模块 'rpy2.robjects.pandas2ri' 没有属性 'ri2py'