nipy / niwidgets

Neuroimaging widgets for jupyter notebooks
http://www.nipy.org/niwidgets
Other
84 stars 34 forks source link

Duplicate Figures Shown on First Render #29

Closed cancan101 closed 6 years ago

cancan101 commented 6 years ago

xposted: https://github.com/jupyter-widgets/ipywidgets/issues/1904

Goes away after moving slider:

image

cancan101 commented 6 years ago

I am using this patch for now:

diff --git a/niwidgets/niwidget_volume.py b/niwidgets/niwidget_volume.py
index 462024f..be2dccf 100644
--- a/niwidgets/niwidget_volume.py
+++ b/niwidgets/niwidget_volume.py
@@ -171,7 +171,8 @@ class NiftiWidget:

         This function is called by _default_plotter
         """
-        if self.image_handles is None:
+        fresh = self.image_handles is None
+        if fresh:
             self._init_figure(data, colormap, figsize)

         coords = [x, y, z]
@@ -204,7 +205,7 @@ class NiftiWidget:
             imh.axes.lines[1].set_ydata(2*[guide_positions[1]])

             imh.set_cmap(colormap)
-
+        if not fresh:
             return self.fig

     def _init_figure(self, data, colormap, figsize):