code: def gg_ipython(plot, data, width=IPYTHON_IMAGE_SIZE, height=None,
                 *args, **kwargs):
      
      try:
          import IPython.display
          tmp_image_filename = tempfile.NamedTemporaryFile(suffix='.jpg').name
          # Quiet by default
          kwargs['quiet'] = kwargs.get('quiet', True)
  
          if width is None:
              raise ValueError("Width cannot be None")
          height = height or width
          w_in, h_in = size_r_img_inches(width, height)
          ggsave(name=tmp_image_filename, plot=plot, data=data,
                 dpi=600, width=w_in, height=h_in, units=esc('in'),
                 *args, **kwargs)
          return IPython.display.Image(filename=tmp_image_filename,
                                       width=width, height=height)
      except ImportError:
          print "Could't load IPython library; integration is disabled"
docs: Render pygg in an IPython notebook
  
      Allows one to say things like:
  
      import pygg
      p = pygg.ggplot('diamonds', pygg.aes(x='carat', y='price', color='clarity'))
      p += pygg.geom_point(alpha=0.5, size = 2)
      p += pygg.scale_x_log10(limits=[1, 2])
      pygg.gg_ipython(p, data=None, quiet=True)
  
      directly in an IPython notebook and see the resulting ggplot2 image
      displayed inline.  This function is print a warning if the IPython library
      cannot be imported.  The ggplot2 image is rendered as a PNG and not
      as a vectorized graphics object right now.
  
      Note that by default gg_ipython sets the output height and width to
      IPYTHON_IMAGE_SIZE pixels as this is a reasonable default size for a
      browser-based notebook.  Height is by default None, indicating that height
      should be set to the same value as width.  It is possible to adjust
      the aspect ratio of the output by providing non-None values for both
      width and height