import uuid
from rpy2.robjects.packages import importr
from IPython.core.display import Image
grdevices = importr('grDevices')

def ggplot_notebook(gg, width=800, height=600):
    fn = '{uuid}.png'.format(uuid=uuid.uuid4())
grdevices.png(fn, width=width, height=height)
gg.plot()
grdevices.dev_off()
return Image(filename=fn)
using rpy2 with IPython notebooks?