0

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?

1 Answers1

1

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
lgautier
  • 11,363
  • 29
  • 42
  • works great thanks! do you happen to have ideas on http://stackoverflow.com/questions/17736434/aligning-distinct-non-facet-plots-in-ggplot2-using-rpy2-in-python ? unresolved issue –  Aug 30 '13 at 23:39