[Yt-svn] yt: Adding a wrapper for the IPython webnb 'inline' backend, whi...

hg at spacepope.org hg at spacepope.org
Wed Dec 22 21:32:50 PST 2010


hg Repository: yt
details:   yt/rev/da3894bf42a5
changeset: 3628:da3894bf42a5
user:      Matthew Turk <matthewturk at gmail.com>
date:
Wed Dec 22 21:32:44 2010 -0800
description:
Adding a wrapper for the IPython webnb 'inline' backend, which is really,
really cool.  This should get us going very simply with the webnb backend, but
the images are pretty huge as is.

diffstat:

 yt/visualization/plot_collection.py |  24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diffs (34 lines):

diff -r efb1a2ffe6f3 -r da3894bf42a5 yt/visualization/plot_collection.py
--- a/yt/visualization/plot_collection.py	Tue Dec 21 10:31:38 2010 -0800
+++ b/yt/visualization/plot_collection.py	Wed Dec 22 21:32:44 2010 -0800
@@ -1664,6 +1664,30 @@
         print 'Returning final width of %e' % self.plots[0].width
         return self.plots[0].width
 
+class PlotCollectionIPython(PlotCollection):
+    def save(self):
+        r"""Shows all the plots hanging off this plot collection in the IPython
+        web notebook.
+
+        This function will instruct the IPython web notebook to show its
+        images.
+
+        Examples
+        --------
+
+        >>> pc.save()
+        """
+        from matplotlib.backends.backend_svg import \
+            FigureCanvasSVG
+        from IPython.zmq.pylab.backend_payload import \
+            add_plot_payload
+        from IPython.zmq.pylab.backend_inline import \
+            send_svg_canvas
+        if basename is None: basename = str(self.pf)
+        for plot in self.plots:
+            canvas = FigureCanvasSVG(plot._figure)
+            send_svg_canvas(canvas)
+
 def get_multi_plot(nx, ny, colorbar = 'vertical', bw = 4, dpi=300):
     r"""Construct a multiple axes plot object, with or without a colorbar, into
     which multiple plots may be inserted.



More information about the yt-svn mailing list