Bug introduced in 10.0 and fixed in 10.3.0

Check this example:

Manipulate[Grid[{{RandomReal[10]}, {Plot[Sin[x], {x, 0, 2 Pi}]}}], {a, 1, 3}]

enter image description here

As you can see, moving or resizing the Notebook window causes Manipulate to update its argument.

Is this normal behavior of MMA?


  • $\begingroup$ Mine doesn't update when moving the window, but does when resizing (Mac OS 10, Mma 10.0.2). Maybe Manipulate feels like it needs to update the graph, because if you remove this part, it no longer updates when resizing. $\endgroup$ – bill s Feb 7 '15 at 22:14
  • $\begingroup$ doesn't happen in Version (Windows 8 x64). $\endgroup$ – kglr Feb 7 '15 at 23:34
  • $\begingroup$ My system is V 10.0.2 (windows 8.1 x64) $\endgroup$ – Algohi Feb 7 '15 at 23:37
  • $\begingroup$ Confirmed on V10.0.2 Win7. I'd report it. It is certainly not expected (by me :)). $\endgroup$ – Kuba Feb 8 '15 at 0:21
  • 1
    $\begingroup$ Probably not related but similar behaviour: WindowSize interfere Dynamic $\endgroup$ – Kuba Feb 8 '15 at 0:24

I think I've found the guilty : this is PlotTheme

Since the problem seems to only occur when "plot" functions are involved, for example here :

Manipulate[Grid[{{RandomReal[10]}, {Plot[Sin[x], {x, 0, 2 Pi}]}}], {a, 1, 3}]

Manipulate[Grid[{{RandomReal[10]}, {ListPlot[Range[10]]}}], {a, 1, 3}]

 Grid[{{RandomReal[10]}, {ParametricPlot[{Cos[t], Sin[t]}, {t, 0, Pi}]}}], {a, 1, 3}]

but not in other cases, in particular when other type of graphics are used, like here :

Manipulate[Grid[{{RandomReal[10]}, {RandomReal[10]}}], {a, 1, 3}]

Manipulate[Grid[{{RandomReal[10]}, {Graphics[Disk[]]}}], {a, 1, 3}]

and as there is no problem with version 9, and since PlotTheme was introduced in version 10, I just tested PlotTheme->None, and the problem disappears.

For example :

 Grid[{{RandomReal[10]}, {Plot[Sin[x], {x, 0, 2 Pi}, PlotTheme -> None]}}], {a, 1, 3}]
|improve this answer|||||
  • $\begingroup$ yes that is the one. +1 $\endgroup$ – Algohi Feb 20 '15 at 12:47
  • $\begingroup$ very good finding, much appreciated... $\endgroup$ – Albert Retey Feb 20 '15 at 14:40
  • 2
    $\begingroup$ Another bad boy is PlotLegends : Manipulate[ Grid[{{RandomReal[10]}, {Plot[{Cos[x], Sin[x]}, {x, 0, 2 Pi}, PlotTheme -> None, PlotLegends -> Automatic]}}], {a, 1, 3}] still triggers updating when moving the notebook (M10.2, Windows).@John Fultz: Can we please get a bug fix soon? $\endgroup$ – Rolf Mertig Sep 26 '15 at 13:11

This bug has been fixed in Mathematica v10.3.


|improve this answer|||||

I consider this a bug. Although I have no solution, I can provide some further insights. The behavior seems to depend on the usage of any plotting command or commands that display something. The smallest example I could find is

Dynamic[{Plot[Null, {a, 0, 1}], AbsoluteTime[]}]

A simple static Graphics seems not enough, but if you use a Graph instead of the Plot, the behavior appears too. If you look at the cell expression, there seems nothing unusual there

    Plot[Null, {$CellContext`a, 0, 1}], 
    AbsoluteTime[]}, StandardForm],
  ImageSizeCache->{404., {46., 51.}}]], "Output",

Therefore, the question is why the front end does trigger a re-evaluation of this DynamicBox.

|improve this answer|||||

EDIT: Everyone reading this should be aware that SquareOne's answer contains the real reason and the best way to get rid of these unwanted updates. I'll leave my answer here as I think it shows useful techniques to avoid unwanted updates in similar cases but using PlotTheme->None is certainly the best solution to the OPs problem...

It probably could be argued that the version 10 behavior is OK as the window size might cause changes in any of the manipulates content, e.g. when using something like ImageSize->Full or CurrentValue[EvaluationNotebook[], WindowSize]. The updates when a window moves could then be explained by details of how WindowSizes and WindowMarging are internally handled which would also explain why that seems to be platform dependent. On the other hand it seems to be a confirmed bug and I certainly would consider this an inacceptable misbehavior when using an explicit TrackedSymbols:>{a} to either the Manipulate or an additional Dynamic wrapper for the Plot.

Apart from that I wanted to share a workaround which seems to avoid the problem but is quite some effort to implement in more complicated cases:

DynamicModule[{output, lastValue},
      If[lastValue=!= a,
        lastValue = a;
        output = Plot[Sin[x], {x, 0, 2 Pi}, 
           PlotLabel -> {a, RandomReal[]}, 
           ImageSize -> {500, 500./GoldenRatio}
      TrackedSymbols :> {a}
    {a, 1, 3}

the following might make the workaround easier to apply to a larger amount of code:


One could of course adopt this to accept more than one tracked symbol and only use that definition instead of a standard Dynamic for those versions which show the erronous behavior.

|improve this answer|||||
  • $\begingroup$ But for other issues like PlotLegends your solution is much more general and better. I.e., this: DynamicModule[{output, lastValue}, Manipulate[DynamicWrapper[output, If[lastValue =!= a, lastValue = a; output = Column[{RandomReal[], Plot[{Cos[x], Sin[x]}, {x, 0, 2 Pi}, PlotLegends -> "Expressions", PlotLabel -> {a, RandomReal[]}, ImageSize -> {500, 500./GoldenRatio}]}]], TrackedSymbols :> {a}], {a, 1, 3}]] works just fine! $\endgroup$ – Rolf Mertig Sep 26 '15 at 13:27
  • $\begingroup$ thanks @RolfMertig , I was hoping it would be helpful and left it here because of that. Have you tried if these unexpected updatesx are still an issue with the latest versions? I'm afraid that this behaviour will stay as it is as a fix might make necessary changes at a very deep level for use cases which WRI might classify as "too exotic" for such a change... $\endgroup$ – Albert Retey Sep 27 '15 at 8:44
  • $\begingroup$ @RolfMertig: just have seen your other comment which exactly answers my question... $\endgroup$ – Albert Retey Sep 27 '15 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.