Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

My code

q1 = {{1, 0.5}, {2, 0.5}}; q2 = 10; q3 = {3, 3};
Dynamic[
  LocatorPane[Dynamic[q1],
    Graphics[{}, 
      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??

share|improve this question
1  
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. –  Kuba Dec 29 '13 at 21:21
1  
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. –  Nasser Dec 29 '13 at 23:13
    
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? –  Coolwater Dec 30 '13 at 12:05

1 Answer 1

up vote 2 down vote accepted

I believe what you want is this:

q1 = {{1, 0.5}, {2, 0.5}}; q2 = 10; q3 = {3, 3};
Dynamic[LocatorPane[Dynamic[q1], 
  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.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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