nipy/niwidgets

Duplicate Figures Shown on First Render

cancan101 opened this issue · 1 comments

xposted: jupyter-widgets/ipywidgets#1904

Goes away after moving slider:

image

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):