Question

I am trying to customize a legend in ggplot2 using rpy2. I notice that ggplot2 through rpy2 does not have scale_shape_discrete and other methods that are shown in http://www.cookbook-r.com/Graphs/Legends_(ggplot2)/ as necessary for customizing legends.

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

What's the correct way to rename/customize discrete legends in ggplot2 through rpy2? Are these methods accessible?

Was it helpful?

Solution

It is missing. You can

1) report the issue on the bitbucket page for rpy2.

2) define it as:

from rpy2.robjects.lib import ggplot2
class ScaleShapeDiscrete(ggplot2.Scale):
    _constructor = ggplot2.ggplot2_env['scale_shape_discrete']
scale_shape_discrete = ScaleShapeDiscrete.new
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top