[yt-svn] commit/yt: MatthewTurk: Merged in ngoldbaum/yt (pull request #2437)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Fri Nov 18 08:13:22 PST 2016


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/f5c8a0e6bfd9/
Changeset:   f5c8a0e6bfd9
Branch:      yt
User:        MatthewTurk
Date:        2016-11-18 16:12:56+00:00
Summary:     Merged in ngoldbaum/yt (pull request #2437)

[bugfix] fix rich display of ProfilePlot in the jupyter notebook
Affected #:  2 files

diff -r d6aed3eef562bdb54864d3786f42d84b25c5aa62 -r f5c8a0e6bfd9253e601f2a0273c9be23c4680add yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -168,6 +168,14 @@
             if font_color is not None:
                 label.set_color(self.font_color)
 
+    def _repr_png_(self):
+        from ._mpl_imports import FigureCanvasAgg
+        canvas = FigureCanvasAgg(self.figure)
+        f = BytesIO()
+        with matplotlib_style_context():
+            canvas.print_figure(f)
+        f.seek(0)
+        return f.read()
 
 class ImagePlotMPL(PlotMPL):
     """A base class for yt plots made using imshow
@@ -215,15 +223,6 @@
         for which in ['major', 'minor']:
             self.cax.tick_params(which=which, axis='y', direction='in')
 
-    def _repr_png_(self):
-        from ._mpl_imports import FigureCanvasAgg
-        canvas = FigureCanvasAgg(self.figure)
-        f = BytesIO()
-        with matplotlib_style_context():
-            canvas.print_figure(f)
-        f.seek(0)
-        return f.read()
-
     def _get_best_layout(self):
 
         # Ensure the figure size along the long axis is always equal to _figure_size

diff -r d6aed3eef562bdb54864d3786f42d84b25c5aa62 -r f5c8a0e6bfd9253e601f2a0273c9be23c4680add yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -326,20 +326,16 @@
     def _repr_html_(self):
         """Return an html representation of the plot object. Will display as a
         png for each WindowPlotMPL instance in self.plots"""
-        from . import _mpl_imports as mpl
         ret = ''
-        unique = set(self.figures.values())
-        if len(unique) < len(self.figures):
+        unique = set(self.plots.values())
+        if len(unique) < len(self.plots):
             iters = izip(range(len(unique)), sorted(unique))
         else:
-            iters = iteritems(self.figures)
-        for uid, fig in iters:
-            canvas = mpl.FigureCanvasAgg(fig)
-            f = BytesIO()
+            iters = iteritems(self.plots)
+        for uid, plot in iters:
             with matplotlib_style_context():
-                canvas.print_figure(f)
-            f.seek(0)
-            img = base64.b64encode(f.read()).decode()
+                img = plot._repr_png_()
+            img = base64.b64encode(img).decode()
             ret += r'<img style="max-width:100%%;max-height:100%%;" ' \
                    r'src="data:image/png;base64,{0}"><br>'.format(img)
         return ret

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list