如何从ggplot2在rpy2中访问theme_classic? [英] how can theme_classic be accessed in rpy2 from ggplot2?

查看:207
本文介绍了如何从ggplot2在rpy2中访问theme_classic?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从Python中的rpy2访问 theme_classic ?即这:

How can theme_classic be accessed from rpy2 in Python? I.e. this:

http://www.inside-r.org/packages/cran/ggplot2/docs/theme_classic

有没有一种方法可以在rpy2中使用它?

Is there a way to use it from rpy2?

推荐答案

是的。如果在 rpy2.robjects.lib.ggplot2 中使用手动映射,那么它目前从那里丢失了,但是修补它的方法应该是:

Yes there is. If using the manual mapping in rpy2.robjects.lib.ggplot2, is it currently missing from there, but a way to patch this should be:

import rpy2.robjects.lib.ggplot2 as ggplot2

class ThemeClassic(ggplot2.Theme):
    _constructor = ggplot2.ggplot2.theme_classic
    @classmethod
    def new(cls):
        res = cls(cls._constructor())
        return res

# Monkey patching ggplot2
ggplot2.theme_classic = ThemeClassic.new

这篇关于如何从ggplot2在rpy2中访问theme_classic?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆