문제

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

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

Is there a way to use it from rpy2?

도움이 되었습니까?

해결책

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top