# automagic conversion of pandas dataframes # to R objects from rpy2.robjects import pandas2ri pandas2ri.activate() # rpy2's mapping of R's ggplot2 from rpy2.robjects.lib import ggplot2 # goodies for ipython (here to plot ggplot2 # in the notebook) from rpy2.interactive import ipython # dummy data import io f = io.StringIO('"x","y"\n1,3\n4,2\n5,6\n2,2\n4.5,4\n3,2.1\n') import pandas dataf = pandas.read_csv(f) # note that 1) the pandas object is used directly # and 2) the ipython-specific constructor ggplot is used ipython.ggplot(dataf) + \ ggplot2.aes_string(x = 'x', y = 'y') + \ ggplot2.geom_point() + \ ggplot2.geom_smooth(method = "loess")