Domanda

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?

È stato utile?

Soluzione

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
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top