Hot answers tagged

8

Keep all your symbols localised to the Manipulate by adding {x, None}, {label, None} at the end. Example: Manipulate[label = TraditionalForm[x - k]; Plot[{Sin[x], Sin[x - k]}, {x, -6, 6}, GridLines -> Automatic, PlotLabel -> Pane[StringForm["y = f(``)", label], 200, Alignment -> Center]], {{k, 0}, -6, 6, 1, Appearance -> ...


7

If you leave ContourPlot outside you can get quite nice performance: static = ContourPlot[45 x^2 + 20 y^2 == 45, {x, -2, 2}, {y, -2, 2}, Frame -> False]; dynamic = ContourPlot[8 x^2 + 4 x y + 5 y^2 == 9, {x, -2, 2}, {y, -2, 2}, Frame -> False, ContourStyle -> Orange]; Manipulate[ Graphics[{ First@static, ...


6

I'm not sure about all the arguments, but maybe this will get you started: Clear[MultiSlider]; MultiSlider[Dynamic[xs_], {st_, end_}] := LocatorPane[Dynamic[xs], Graphics[{LightGray, Thickness[0.015], Line[{{st, 0}, {end, 0}}]}], {{st, 0}, {end, 0}}] Manipulate[ x, {{x, Table[{2 i, 0}, {i, 5}]}, 0, 12, MultiSlider[##] &}] You can constrain ...


4

Use Normal to get the lists out of a TemporalData object Normal[td] returns a list containing time-value pairs for each path. s = {2, 1, 6, 5, 7, 4}; s2 = {22, 12, 62, 52, 72, 42}; t = {1, 2, 5, 10, 12, 15}; td = TemporalData[{s, s2}, {t}]; Normal@td (* {{{1, 2}, {2, 1}, {5, 6}, {10, 5}, {12, 7}, {15, 4}}, {{1, 22}, {2, 12}, {5, 62}, {10, 52}, ...


4

A simple way is to define your Manipulate variable parameters so that they are recognised as the control type you want. Look in the first part of the Details and Options section of Manipulate documentation. Manipulate[ Plot[Sin[a + b x], {x, 0, 10}], {{a, 0}, {0, 1}}, {b, 1, 5}] You can get fancier by specifying the controls and layout directly. ...


3

Use the second argument to Dynamic. Example: DynamicModule[{NumSelec = {}}, Column[{ CheckboxBar[ Dynamic[NumSelec, (If[Length[#] > 2, NumSelec = #[[-2 ;;]], NumSelec = #]) &], {1, 2, 3, 4}], Dynamic[NumSelec] }] ]


3

Edit I have edited this answer to address issues raised by the OP in a deleted answer that should have been posted as a comment to this one. There seem to be two problems with your code. This is one of those times when you must use Set rather than SetDelayed when defining a function. You shouldn't use s_ in a function call, as you did in your Manipulate ...


3

You can use LabelStyle -> Directive[Bold, Red] and LabelStyle -> Directive[Bold, Blue] Manipulate[ If[reflection, Plot[{-func}, {x, -3, 3}, PlotStyle -> Red, PlotRange -> {{-3, 3}, {-3, 3}}, GridLines -> Automatic, PlotLabel -> StringForm["f(x) = ``", -func], LabelStyle -> Directive[Bold, Red]], Plot[{func}, {x, -3, ...


3

EDIT: added use of PlotLegends package Use a single Plot with the option Filling Needs["PlotLegends`"]; EffPot[r_, Energy_, AngMom_] := -Energy/r + (AngMom^2 - 1)/(2 r^2) Manipulate[ Plot[{ EffPot[r, Energy, AngMom], (Energy^2 - 1)/2}, {r, 0, 10}, PlotStyle -> { {Thick, RGBColor[0.60, 0.20, 0.40]}, {Thick, RGBColor[0.20, 0.20, ...


3

You have put the plot to the second argument of Manipulate, while there are some examples around with different things there it is really meant only for controllers. So what you have to do is to gather your output in the first argument of Manipulate, with a Grid or something: [...] Column[{ Button["Plot", plot = Plot3D[Sin[x + y^0], {x, -3, 3}, {y, -2, ...


3

r = 2; Manipulate[ Plot[q t E^(Subscript[B, 2] + Subscript[B, 1] t^n), {t, -10, 10}, PlotRange -> All, PlotPoints -> 50], {q, -r, r}, {Subscript[B, 1], -r, r}, {Subscript[B, 2], -r, r}, {n, -r, r} ]


3

The FrontEnd has the habit of renaming variables, which is usually a good thing, but sometimes can be troublesome. One possibility is to evaluate the argument of Plot, e.g.: Manipulate[ NumberForm[ Plot @@ {{a Sin[x], a Cos[x]}, {x, 0, 2 Pi}, PlotLegends -> "Expressions", PlotRange -> {-2, ...


2

Edit TemporalData is one of those functions that accepts property names as arguments for extracting the information it holds. Please read the documentation for TemporalData where will find a list of such properties and examples of their use. Using example data taken from the documentation s = {2, 1, 6, 5, 7, 4}; s2 = {22, 12, 62, 52, 72, 42}; t = {1, 2, ...


2

You can fix this by wrapping the plotting function inside an Evaluate: Manipulate[ Plot[ Evaluate[(f /. x -> (x - h)) + k] , {x, -10, 10} , PlotRange -> {{-10, 10}, {-10, 10}} , Epilog -> Text[(f /. x -> (x - h)) + k, {7, 9}] , GridLines -> {Range[-10, 10], Range[-10, 10]} , GridLinesStyle -> Opacity[.04] ] , {{f, x^2, ...


2

This is a classic case where a good solution is to define a function. sphereCenter = {0, 0, 0}; sphere[sphereRadius_] := Sphere[sphereCenter, sphereRadius]; Manipulate[Graphics3D[sphere[s], PlotRange -> {{-10, 10}, {-10, 10}, {-10, 10}}], {s, 1, 10}] I added the PlotRange, because otherwise you can't see the ball getting larger and smaller due to ...


2

As Sascha has note in a comment, you need to define your queueing process as a function of λ. q[λ_] := QueueingProcess[λ, 4.3, 1] Manipulate[ QueueProperties[q[λ]], {λ, 1, 4, Appearance -> "Labeled"}]


2

One problem you're having is that because Manipulate localizes its variables, while the symbols in par are global (in the "Global`" context), the letters a, b, c inside the Manipulate do not refer to the variables in par. Your workaround seems reasonable. There's also the option LocalizeVariables, which can be set to False to make the Manipulate parameters ...


2

The problem is with the function evaluating at each point of plot instead of being set once and for all. This is due to the misuse of setdelayed (:=). end = 5; delta :=RandomChoice[{0.08, -0.08, 0.16, -0.16}]; f[x_] = Piecewise[ Table[{Sin[x Pi + delta]^100, i <= x < i + 1}, {i, 0, end-1}]]; Plot[f[x], {x, 0, end}, PlotRange -> All, PlotPoints ...


2

I just want to point out the Edmund's fancy version of Manipulate is unnecessarily complicated. The same effects can be gotten with much simpler code. Manipulate[ Plot[Sin[a + b x], {x, 0, 10}], Row[{ Control[{{a, 0, ""}, {0, 1}}], " ", Dynamic @ Switch[a, 0, "Zero", 1, "One"]}], {{b, 1, ""}, 1, 5, Appearance -> "Labeled"}] ...


1

In addition to what Mike Honeychurch advised one further reason for problems may be that many dynamic object working at once may be too difficult for your computer. Only those Manipulates are active that are actually on the screen. However, these also may be too much in some cases. I always try to have different Manipulatestatements on different pages of my ...


1

You can control the automatic switching between when a control (e.g. slider) is actively being moved and when it has been releeased with ControlActive. Better rendering takes more time, so it is up to the programmer to balance quality and speed, if the Automatic setting is unsatisfactory. See also PerformanceGoal. sol = DSolve[{D[u[t, x], t] - x*D[u[t, ...


1

The simplest way I thick is to use Dynamic["your function"] instated of 1 in your controller. Control[{{A, 0.1, "Amplitude"}, 0, Dynamic["your function"], 0.01, Appearance -> {"Labeled", "Closed"}}] I think this will give you want you want, (assuming the function of the end is f+1): Manipulate[ Plot[A Sin[2 Pi f t/12], {t, 0, 12}, PlotRange -> ...


1

There is really no need to gather the parameters into a list. You can do it with this simple approach. DynamicModule[{f, g}, f[q_, a_, b_, c_] := q + 2 a + 3 b + 4 c; g[q_, u_, v_, w_] := q - u/2 - v/3 - w/4; Manipulate[ Plot[f[q - 5, a, b, c]^2 + g[q + 5, a, b, c]^2, {q, 0, 10}], {{a, 0}, -1, 1}, {{b, 0}, -1, 1}, {{c, 0}, -1, 1}]] ...


1

Here's a way using a function to rewrite the dynamic value when length of 2 is exceeded. Manipulate[ NumSelec = limit[NumSelec, 2], {NumSelec, {1, 2, 3, 4}, ControlType -> CheckboxBar}, Initialization :> ( limit[x_, num_] := If[ListQ[x], If[Length[x] > num, x[[-num ;;]], x], x]) ]


1

This is one way using DynamicModule DynamicModule[{NumSelec1 = {}, NumSelec2 = {}, NumSelec3 = {}, false}, Column[{ Dynamic@ Row[{CheckboxBar[Dynamic[NumSelec1], {1}, Enabled -> (NumSelec1 =!= {} || false)], CheckboxBar[Dynamic[NumSelec2], {2}, Enabled -> (NumSelec2 =!= {} || false)], ...


1

Changing initial conditions can be accomplished in the same way that parameters are changed. For instance, replace Yb[0] == 0.1 by Yb[0] == Yb0, add the corresponding control, {{Yb0, 0.1}, 0, 1, Appearance -> "Labeled"}, and include Yb0 in the list of TrackedSymbols.


1

If there is a need to preserve initial structure of the code, some condition may be an option: Manipulate[ dom = {-10, 10}; If[Not[NumericQ[f]] || Not[Between[f, dom]], f = 0]; Plot[a Sin[2 Pi f t/12], {t, 0, 12}, PlotRange -> {{0, 12}, {-1, 1}}, AspectRatio -> 0.5, Frame -> True, Axes -> True, ImageSize -> 800], Row[{ ...


1

You can avoid trouble by choosing reasonable values for the range and increment of your controls. The following choices work well. Manipulate[ Plot[a Sin[2 Pi f t/12], {t, 0, 12}, PlotRange -> {{0, 12}, {-1, 1}}, AspectRatio -> 0.5, Frame -> True, ImageSize -> 700], Row[{ Control[{{f, 1, "frequency"}, 0, 10, 0.01, ...


1

To address the issue use some Off[NumberForm::sigz] in Manipulate[...]. It is also better to use simple Epilog with Text[Row[...] (code below): Some code picture:


1

You can avoid the Which by dynamically setting PlotRange and FrameStyle as a function of f Manipulate[ Plot[f[x], {x, 0, 10}, PlotRange -> {Automatic, {0, Max[axisStep Quotient[f[1], axisStep], 2]}}, Frame -> True, FrameStyle -> {With[{z = Mod[f[1], axisStep]}, If[flashRange > z \[Or] z > axisStep - flashRange, ...



Only top voted, non community-wiki answers of a minimum length are eligible