Plot windows get placed on top of each other

Bug #947090 reported by Anders Logg
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Viper
Fix Released
Medium
Joachim Haga

Bug Description

When plotting several functions in a time loop, the plot windows are placed on top of each other and moving the windows manually does not help since the plot windows are moved back to the original location in each time step.

Revision history for this message
Joachim Haga (jobh) wrote :

I thought I did this last year, see revision <email address hidden>

Doesn't it work? You're plotting separate functions (so the update logic doesn't kick in)? It may also be worth trying autoposition=False.

If autoposition=False helps, then it might just be missing a test if the window is newly created or updated (if updated, the placement shouldn't be changed).

Revision history for this message
Anders Logg (logg) wrote : Re: [Bug 947090] Re: Plot windows get placed on top of each other

On Mon, Mar 05, 2012 at 01:09:01PM -0000, Joachim Haga wrote:
> I thought I did this last year, see revision
> <email address hidden>
>
> Doesn't it work? You're plotting separate functions (so the update logic
> doesn't kick in)? It may also be worth trying autoposition=False.
>
> If autoposition=False helps, then it might just be missing a test if the
> window is newly created or updated (if updated, the placement shouldn't
> be changed).

Thanks, autoposition=False helps.

I'm plotting like this:

  f = Expression("...")
  _f = Function(V)

  while t < T:

      f.t = t
      _f.interpolate(f)
      plot(_f)

So it should be a plain update.

--
Anders

Revision history for this message
Joachim Haga (jobh) wrote :

The following hack is only very lightly tested, but should "fix" it.

=== modified file 'src/viper/viper_dolfin.py'
--- src/viper/viper_dolfin.py 2012-02-09 09:06:11 +0000
+++ src/viper/viper_dolfin.py 2012-03-05 14:43:26 +0000
@@ -410,11 +410,16 @@
             return self.autoplot(plot_object, *args, **kwargs)
         return self.figureplot(plot_object, *args, **kwargs)

- def autoplot(self, plot_object, *args, **kwargs):
+ def get_plotter(self, plot_object):
         for (idx, (plotter,obj)) in self.plots.items():
             if obj is plot_object:
- plotter.update(plot_object, **kwargs)
                 return plotter
+
+ def autoplot(self, plot_object, *args, **kwargs):
+ plotter = self.get_plotter(plot_object)
+ if plotter:
+ plotter.update(plot_object, **kwargs)
+ return plotter
         idx = self.random.randint(0,10000)
         keys = self.plots.keys()
         while idx in keys:
@@ -452,6 +457,8 @@
     global _plotter
     if _plotter is None:
         _plotter = PlotManager()
+
+ new_window = not _plotter.get_plotter(data)
     n_old_plots = len(_plotter.plots)

     interactive = False
@@ -460,7 +467,7 @@
         kwargs["interactive"] = False
     fig = _plotter.plot(data, **kwargs)

- if n_old_plots > 0 and kwargs.get('autoposition', True):
+ if new_window and kwargs.get('autoposition', True):
         x, y = fig.window_size
         nx, ny = n_old_plots%3, n_old_plots//3
         fig.renWin.SetPosition(nx*x, ny*y)

Revision history for this message
Anders Logg (logg) wrote :

Thanks! This seems to do the trick. Patch applied.

--
Anders

On Mon, Mar 05, 2012 at 02:46:59PM -0000, Joachim Haga wrote:
> The following hack is only very lightly tested, but should "fix" it.
>
> === modified file 'src/viper/viper_dolfin.py'
> --- src/viper/viper_dolfin.py 2012-02-09 09:06:11 +0000
> +++ src/viper/viper_dolfin.py 2012-03-05 14:43:26 +0000
> @@ -410,11 +410,16 @@
> return self.autoplot(plot_object, *args, **kwargs)
> return self.figureplot(plot_object, *args, **kwargs)
>
> - def autoplot(self, plot_object, *args, **kwargs):
> + def get_plotter(self, plot_object):
> for (idx, (plotter,obj)) in self.plots.items():
> if obj is plot_object:
> - plotter.update(plot_object, **kwargs)
> return plotter
> +
> + def autoplot(self, plot_object, *args, **kwargs):
> + plotter = self.get_plotter(plot_object)
> + if plotter:
> + plotter.update(plot_object, **kwargs)
> + return plotter
> idx = self.random.randint(0,10000)
> keys = self.plots.keys()
> while idx in keys:
> @@ -452,6 +457,8 @@
> global _plotter
> if _plotter is None:
> _plotter = PlotManager()
> +
> + new_window = not _plotter.get_plotter(data)
> n_old_plots = len(_plotter.plots)
>
> interactive = False
> @@ -460,7 +467,7 @@
> kwargs["interactive"] = False
> fig = _plotter.plot(data, **kwargs)
>
> - if n_old_plots > 0 and kwargs.get('autoposition', True):
> + if new_window and kwargs.get('autoposition', True):
> x, y = fig.window_size
> nx, ny = n_old_plots%3, n_old_plots//3
> fig.renWin.SetPosition(nx*x, ny*y)
>

Changed in fenics-viper:
assignee: nobody → Joachim Haga (jobh)
importance: Undecided → Medium
status: New → Fix Committed
Changed in fenics-viper:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.