My code

q1 = {{1, 0.5}, {2, 0.5}}; q2 = 10; q3 = {3, 3};
      PlotRange -> {{0, Dynamic[q2]}, {-1, 1}},
      Axes -> True], 
    Appearance -> q3], 
  TrackedSymbols :> {q3}]

is wrong, because when I press this button

Button["Add", AppendTo[q1, {q1[[-1, 1]] + 1, 0.5}]; AppendTo[q3, 1]]

a bad output cell appears, and I get the mesage

The specified setting for the option GraphicsBoxOptions, PloRange cannot be used."

What is wrong here??

  • 1
    $\begingroup$ I don't know but if you leave q2 without Dynamic it will work, also wrapping LocatorPane and Button with e.g. Column will prevent the error too. $\endgroup$ – Kuba Dec 29 '13 at 21:21
  • 1
    $\begingroup$ as Kuba said, the problem is that you wrapped q2 in Dynamics. Dynamics is for display only. Nothing that has Dynamics will be understood by the Kernel. only the FE` understands dynamics. So passing a Dynamics to PlotRange is not going to work. Dynamics should be an outermost wrapper, something that can be only handled by the FE' and not send to the kernel. $\endgroup$ – Nasser Dec 29 '13 at 23:13
  • $\begingroup$ From what i read about Dynamic[], I should nest them to avoid the whole LocatorPane[...] expression to be reevaluated whenever q2 changes (why would that be necessary?). Not true? $\endgroup$ – Coolwater Dec 30 '13 at 12:05

I believe what you want is this:

q1 = {{1, 0.5}, {2, 0.5}}; q2 = 10; q3 = {3, 3};
  Graphics[{}, PlotRange -> Dynamic@{{0, q2}, {-1, 1}}, Axes -> True],
   Appearance -> q3], TrackedSymbols :> {q3}]

You can have a dynamic PlotRange, but you have to wrap the whole range specification with Dynamic.

  • $\begingroup$ I think there is still something missing. Try {Dynamic[LocatorPane...] , Button[...]} and later Column@{Dynamic[LocatorPane[...]], Button[...]}, with PlotRange->{{0, Dynamic@q2},{...}} $\endgroup$ – Kuba Dec 30 '13 at 7:00
  • $\begingroup$ Something is missing? Would you please clarify, because the code seems perfectly fine to me. $\endgroup$ – Coolwater Dec 30 '13 at 12:11
  • $\begingroup$ I tried Dynamic[Print[0];LocatorPane[(*Michael E2 answer, except for "TrackedSymbols:>{q3}"*)] and found that option to be unnecessary. $\endgroup$ – Coolwater Dec 30 '13 at 12:22
  • $\begingroup$ @Coolwater I meant, it works but I don't understand something with the behaviour of FE here. :) This answer works ok. $\endgroup$ – Kuba Dec 30 '13 at 18:04

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.