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
.
Problem:
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:
Manipulate[
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
Slider[Dynamic[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.)