equivalent of scale_size_area in rpy2 for ggplot2 in Python? -
does rpy2 have equivalent of scale_size_area() ggplot2? if not, how can write it? i'm referring function:
http://docs.ggplot2.org/0.9.3/scale_size_area.html
i scale points size according area, not radius believe default.
no, rpy2 not have feature since ggplot2 wrapper module hand coded. (hopefully, author notes metaprogramming used make code shorter , more automatic.) however, news is not hard add own feature. here's how add scale_size_area() existing functionality:
import rpy2.robjects.lib.ggplot2 ggplot2 import rpy2.robjects ro mtcars = ro.r('mtcars') gp = ggplot2.ggplot(mtcars) pp = gp + ggplot2.aes_string(x='wt', y='mpg', size='cyl') + ggplot2.geom_point() # using standard size (radius) aesthetic size pp.plot() # create scalesizearea (based on ggplot2.py in rpy2) class scalesizearea(ggplot2.scalesize): _constructor = ggplot2.ggplot2_env['scale_size_area'] ggplot2.scale_size_area = scalesizearea.new # can use scale_size_area instead! pp_area = pp + ggplot2.scale_size_area() pp_area.plot()
Comments
Post a Comment