Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Currently, I am working with some dynamic simulations of mechanical/electrical systems (in this case a kitchen scale). The main simulation is running smoothly but while building a nice GUI around the simulation I encountered a problem with creating a plot using Manipulate.


I would like to have the plot with either Full as PlotRange or (by toggling a radio button / togglerbar/ checkbox) or with a slider to control the vertical PlotRange. I tried putting Evaluate around my dynamic variable(s) as well as putting Dynamic around Plot, but the common outcome is that the radio buttons, togglebars or checkboxes "jump" out of their position and the Plot does not update. Moving the slider and afterwards toggling into "Slider-mode" results in correctly scaled axes. My code:

Dynamic[Plot[Sin[t], {t, 0, 5}, 
PlotRange -> {{0, 5}, 
Evaluate@scalefunction}]], {scalefunction, {Full, {-scale, 
scale}}, ControlType -> RadioButtonBar}, {scale, 1, 5}]

Since this method did not work out, I tried to do the same without Manipulate:

The following line creates my variable scale2 that I'd like to use with PlotRange. It switches from Full to {-scaleIntern, scaleIntern} as was planned.

{Checkbox[Dynamic[scale2], {Full, {Evaluate@Dynamic[-scaleIntern], 
Evaluate@Dynamic[scaleIntern]} }], Dynamic[scale2]}

This is the Slider to control scaleIntern


The following line then creates my dynamic Plot

Dynamic[Plot[Sin[t] , {t, 0, 2 \[Pi]}, 
PlotRange -> {{0, 2 \[Pi]}, Evaluate@scale2}]]

Strange is the error from the messages window:

Plot::prng: Value of option PlotRange -> {{0,2 \[Pi]},{-0.559,0.559}} is not All, Full, 
Automatic, a positive machine number, or an appropriate list of range specifications. >>

The number +-0.559 is interactively bound to my slider and due to the correct format of my range specification the error message does not help me to find the problem I've been having with my code.

I would really appreciate any aid to solve the issue. (I don't really care which method is going to work out in the end, but I am interested in the solution of both for interests sake.)

share|improve this question
up vote 5 down vote accepted

You are making it too complicated. Also, Why is Plot being wrapping in Dynamics inside Manipulate like you did? Manipulate is a Dynamic Module.

How about simply making that when the slider is zero, then it will default to Full. This way, one less button to use on the UI. When the scale is not zero, then the scale is used for the plot range. Hence the slider acts for both things. Something like

share|improve this answer
My first thought was that an indication(via radio-button) which mode is in use would be helpful since no further explanation is necessary. But on second thought your idea looks a lot cleaner GUI-wise. About the dynamic inside Manipulate: While experimenting with this very example (and the kind of "nested" manipulators) I noticed that the Plot does respond to the Slider, not interactively but when it refreshes through the usage of the radio-buttons. – Sascha Nov 11 '12 at 2:28

Do you need something like this?

 Row@{VerticalSlider[Dynamic@scale, {0.5, 2}], 
   Dynamic@Plot[Sin[t], {t, 0, 5}, 
     PlotRange -> {{0, 5}, {-scale, scale}}]}]
share|improve this answer

Your Answer


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.