Ejemplo n.º 1
0
#      ggplot2.aes_string(x='wt', y='mpg') + \
#      ggplot2.geom_point() + \
#      ggplot2.scale_y_reverse()

# pp.plot()
# #-- ggplot2coordtransreverse-end
# grdevices.dev_off()

grdevices.png('../../_static/graphics_ggplot2map_polygon.png',
              width=612,
              height=612,
              antialias="subpixel",
              type="cairo")
#-- ggplot2mappolygon-begin
map = importr('maps')
fr = ggplot2.map_data('france')

# add a column indicating which region names have an "o".
fr = fr.cbind(fr, has_o=base.grepl('o', fr.rx2("region"), ignore_case=True))
p = ggplot2.ggplot(fr) + \
    ggplot2.geom_polygon(ggplot2.aes(x = 'long', y = 'lat',
                                     group = 'group', fill = 'has_o'),
                         col="black")
p.plot()
#-- ggplot2mappolygon-end
grdevices.dev_off()

grdevices.png('../../_static/graphics_ggplot2mtcars_coordtrans.png',
              width=936,
              height=624,
              antialias="subpixel",
Ejemplo n.º 2
0
# #-- ggplot2coordtransreverse-begin
# pp = gp + \
#      ggplot2.aes_string(x='wt', y='mpg') + \
#      ggplot2.geom_point() + \
#      ggplot2.scale_y_reverse()

# pp.plot()
# #-- ggplot2coordtransreverse-end
# grdevices.dev_off()


grdevices.png('../../_static/graphics_ggplot2map_polygon.png',
              width = 612, height = 612, antialias="subpixel", type="cairo")
#-- ggplot2mappolygon-begin
map = importr('maps')
fr = ggplot2.map_data('france')

# add a column indicating which region names have an "o".
fr = fr.cbind(fr, has_o = base.grepl('o', fr.rx2("region"),
                                     ignore_case = True))
p = ggplot2.ggplot(fr) + \
    ggplot2.geom_polygon(ggplot2.aes(x = 'long', y = 'lat',
                                     group = 'group', fill = 'has_o'),
                         col="black")
p.plot()
#-- ggplot2mappolygon-end
grdevices.dev_off()