Question

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?

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top