From 17ec8971a36437b21242b01411c0fbaf1c42dfd5 Mon Sep 17 00:00:00 2001 From: Ali Ebrahim Date: Fri, 4 Jan 2013 12:34:36 -0800 Subject: [PATCH] add png visualization in ipython notebook Add a _repr_png_ method to ghost to give a png preview of plots in the notebook. --- pygal/ghost.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pygal/ghost.py b/pygal/ghost.py index 5dff44f..e7b5704 100644 --- a/pygal/ghost.py +++ b/pygal/ghost.py @@ -102,3 +102,7 @@ class Ghost(object): """Render the graph, convert it to png and write it to filename""" import cairosvg return cairosvg.svg2png(bytestring=self.render(), write_to=filename) + + def _repr_png_(self): + """Display png in IPython notebook""" + return self.render_to_png()