Tag Info

Hot answers tagged

8

You can make the Locators a part of the Graphics object instead of the Manipulate: Manipulate[pts = PadRight[pts, n, RandomReal[{-1, 1}, {15, 2}]]; disp = Graphics[{Polygon[pts], PlotRange -> 1, Locator /@ pts}], {n, 5, 15, 1}, {{pts, {{0, 0}}}, Locator, Appearance -> None}] Now you'll get a disp that looks like


5

The problem is that trajectory[f] passes the Symbol f to Manipulate, so that the Manipulate updates to the new f whenever the definition of f is changed. The trick is to somehow to evaluate f so that the symbol f is replaced by its definition before it is injected into the Manipulate code. Method 1: ClearAll[soln]; soln[f0_, y0_] := Function[t0, y[t0] ...


5

The MapIndexed function works very nicely for this, as it provides both the value of the array element, and a list representing its position. I wasn't golfing here, so I used pattern matching on function arguments for the rest: draw[0, _] = {}; draw[v : Except[0], {x_, y_}] := {v /. {0.5 -> Green, 1 -> Red}, Sphere[{x, 6 - y, 0}]}; Graphics3D[{ ...


4

Your code can be simplified. In particular, I recommend that you get rid of the embedded DynamicModule and, instead, use a common trick of defining invisible controls to localize temporary variables. Manipulate[ s0 = 1 - i0; γ = 1/l; sol = NDSolve[{ s'[t] == -β/(E^(k (t - τ)))*s[t]*i[t], i'[t] == β/(E^(k (t - τ)))*s[t]*i[t] - γ*i[t], ...


4

Change: sol = NDSolve[ ___ ] ... By sol = First@NDSolve[ ___ ] result:


4

Manipulate[ToExpression[func, TraditionalForm] /. x -> val, {{val, Pi, "x"}, InputField}, {{func, "", "f(x)"}, InputField[##, String] &}]


4

Here's an approach. With a little Rule/ReplaceAll manipulation, it can accommodate some typical errors due to inattention to details of syntax. These can be removed if it is a goal to get students to enter proper Mathematica syntax. Adapting some code from rcollyer, we can catch ] messages and display them inside the Manipulate if the user types ...


4

Try this: a = Import["ExampleData/lena.tif"]; Manipulate[ Row[{Image[a, ImageSize -> 80] , Show[ParametricPlot3D[ r*{Cos[u]*Sin[v], Cos[u]*Cos[v], Sin[u]}, {u, -Pi/2, Pi/2}, {v, 0, 2 Pi}, PlotRange -> {-9, 9}, PerformanceGoal -> "Quality", PlotStyle -> {Directive[Yellow, Opacity[0.74]]}]]}], {r, 3, 6}] Putting the ...


3

You can do this: Manipulate[Evaluate@Sin[Slot[n]] &[0, Pi/2], {{n, 1}, Range[2]}] but I don't think it is as handy as: Manipulate[Sin[{0, Pi/2}[[n]]], {{n, 1}, Range[2]}]


3

Manipulate has Attributes HoldAll. Try this: Manipulate[AccountingForm[x[a, b, c], DigitBlock -> 3], Evaluate[Sequence @@ parmsForSlider]]


2

To answer your question literally, you could specify an ImageSize in the Graphics. Note that Animate (as opposed to Manipulate) actually fixes the box size for you. Manipulate is a "stupid" function in that it will just spit out exactly what you have inside it (this is more powerful in general). What you are probably looking for though is fixed coordinates, ...


2

You might want to consider a simple implementation with a Toggler. The only change you will need to make to your code is to explicitly set the image size of the histograms (because if the image size option is left at the default Automatic, the Toggler will shrink them down). Reproducible data. SeedRandom[42]; data1 = RandomVariate[NormalDistribution[0, ...


2

The documentation for EmpiricalDistribtuion states that it operates on a List, multiple Lists or a set of Rules. If we look at the Head of your symbol, delays, we see that it is Dataset, which is not one of the argument forms that EmpiricalDistribution understands. The documentation for Normal states that it will convert a symbol with Head = Dataset to a ...


2

Update: You can also use GetCoordinates from the right-click menu: f[v_, t_] := 91.4 + (91.4 - t) (0.023 v - 0.304 Sqrt[v] - 0.474); ContourPlot[f[v, t], {v, 4, 45}, {t, -60, 30}, ContourLabels -> True] Use CoordinatesToolOptions to customize the content displayed: ContourPlot[f[v, t], {v, 4, 45}, {t, -60, 30}, ContourLabels -> True, ...


2

Manipulate[ Column@{Dynamic[MousePosition["Graphics", "Mouse not in graphics!"]], ContourPlot[91.4 + (91.4 - t) (0.023 v - 0.304 Sqrt[v] - 0.474), {v, 4, 45}, {t, -60, 30}, ContourLabels -> True]}, {{spot, {30, 15}}, {5, -60}, {45, 25}, Locator}]


2

You have a few syntax errors. Here you have them corrected and an example on how to change each component styling: Manipulate[ y[t] /. First@ DSolve[{a y''[t] + b y'[t] + c y[t] == r, y[t0] == ic, y'[t0] == icp}, y[t], t], {{a, 1, "a"}}, {{b, 1, "b"}}, {{c, 1, "c"}}, {{r, 0, "r(t)"}}, {{t0, 0, "t0"}}, {{ic, 0, "y[t0]"}}, {{icp, 0, Style["y'[t0]", ...


2

Using Map, you can avoid looping: Graphics3D[{Opacity[0.5], {Red, Sphere /@ (Position[M, 1] /. {x_, y_} :> {x, 6 - y, 0})}, {Green, Sphere /@ (Position[M, .5] /. {x_, y_} :> {x, 6 - y, 0})}}] or a little shorter (but more nerdy): Graphics3D[{Opacity[0.5], ...


2

A simple workaround is to use Part and SlotSequence like this: ColorData[col][{##}[[n]]] Another workaround is to generate the function that is applied (@@@) with another function: pointslf[1] = RandomReal[1, {12, 7}]; Manipulate[DynamicModule[{min, max, col, fn}, {min, max} = Through@{Min, Max}@pointslf[1][[All, n]]; col = {"TemperatureMap", {min, ...


1

Manipulate version. Manipulate[ Row@string , Column[{Dynamic[pop /@ Range[n] // Row, TrackedSymbols :> {n}], SetterBar[ Dynamic[x, If[# === "+", n++; string = Join[string, {"a"}], n--; string = Most@string] &], {"+", "-"}]}] , {x, None}, {n, None}, {string, None} , Initialization :> ( pop[i_] := With[{j = ...


1

Not sure how you want to place the displaypoints relative to the boxes, but ... you can find the coordinates of the bounding boxes using the ChartElementFunction as follows: Manipulate[Module[{boundingboxes = {}}, Row[{BoxWhiskerChart[data, ChartStyle -> {Red, Purple}, ImageSize -> 400, BarOrigin -> barorigin, BarSpacing -> {within, ...


1

"...is incomplete; more input is needed" is just one of your problems. "More input required" appears because you put the [ on a different line than Manipulate. For example Sin [f[x]] will generate the same error message. Another problem is that NDSolve doesn't return what you think it should return. You didn't mention this, but you could have just tried ...


1

Maybe Manipulate can still be useful: ClearAll[plot]; Do[ plot[a, b] = Plot[a*(x - b)^2, {x, -5, 5}, PlotRange -> {{-5, 5}, {0.0, 4.0}}], {a, .1, 1.0, 0.1}, {b, 0, 1, .1}]; Manipulate[ plot[a, b] , {a, .1, 1.0, 0.1}, {b, 0., 1, .1} ] Keep in mind that the number of frames you want to precalculate is growing fast with number of ...


1

Replacing two instances of e by j in the code allows it to run correctly both as a notebook and a cdf.


1

Few notes: try to avoid Manipulate for complex things. When you have multiple controllers (of the same variable) inside body of Manipulate it triggers evaluation unless you use nested Dynamic/Refresh. Moreover, referring your last example, take a look at: Function[{m, r}, Round[m, r]][Dynamic[5.5], 1]. DynamicModule[{n = 10.123, interval = {10, 20}}, ...


1

delays = d[All, "Delay"]; e = delays[EmpiricalDistribution]; (* or e = Query[EmpiricalDistribution][delays] *) Through@{Mean, Variance, Quantile[#,.3]&}@e (* {10.42, 0.0010972, 10.396} *) Query[{Mean, Variance, Quantile[#, .3] &}][delays]//Normal (* {10.42, 0.0010972, 10.396} *) Plot[CDF[e,x],{x,10,11}] ...


1

To combine the 2 plots, you can use Show. In addition, since Show takes its options from the first plot, you can override these by using PlotRange->All in the Show itself, at the end. Like this Manipulate[ Show[ Plot3D[...], Plot3D[...], PlotRange -> All ] , ....]


1

This will easily generalize to more than two histograms: Manipulate[ Switch[whichHistogram, 1, histo1, 2, histo2 ], {{whichHistogram, 1, "Choose histogram"}, {1 -> "blue", 2 -> "green"}} ]


1

Quick answer put it as a specification of the controller Manipulate[x, {{x, 0}, 0, 100, BaseStyle -> FontSize -> 25}, ControlType -> InputField] Quick notes Nonuniform styles handling is really annoying, one have to always remember what can be inherited and what not or put explicit directives everywhere. I asked it already in Are there ...



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