Tag Info

New answers tagged

5

Body of Manipulate is wrapped by Dynamic and Dynamic doesn't know what's inside inner Dynamics, that's how we can screen a variable to not prompt the very outer Dynamic to evaluate: Manipulate[ e = RandomVariate[NormalDistribution[0, sigma], n]; {Dynamic@a, e}, {{n, 3}, 1, 5, 1, Appearance -> "Labeled"}, {{sigma, 1}, 1, 2, Appearance -> ...


2

You don't need to write code to find cycles. There is a built-in function for that (FindCycle) Besides, using pattern matching for this goal as you did is bound to be rather slow. For visualization of the cycles you can use HighlightGraph. g = Graph[Rule @@@ a, VertexLabels -> "Name"] cycles = FindCycle[g, Infinity, 99999] Manipulate[ ...


3

I made a few changes to your code: First, I moved all of the Import code to outside of the Manipulate. This is better for interactive performance and prevents the same Import from being done multiple times. I put the makes of all available years in the two dimensional list makes (so any row now contains all the makes for a specific year). I also added a ...


0

Here's one approach: Manipulate[ Module[{}, If[0 < vLIQ <= 1, Pause[0.1]; vLIQ = vLIQ + 0.01;, vLIQ = 0]; vol = vLIQ; Graphics[{FaceForm[Opacity[0.6, Green]], Rectangle[{0, 0}, {0.5, vol}], EdgeForm[Thick], FaceForm[None], Rectangle[{0, 0}, {0.5, 1}], Thick, Black, Line[{{0, vol}, {0.6, vol}}], Text[Style[vol, 16], {0.7, ...


2

This is an aside. You might want to use Row[{{{m}, {n}} // MatrixForm, " = ", Binomial[n, m]}] It displays better. For example, With[{m = 2, n = 6}, Row[{{{m}, {n}} // MatrixForm, " = ", Binomial[n, m]}]]


7

You could use Manipulate[If[m > n, m = n]; Row[{"(", Column[{n, m}, Center], ") = ", Binomial[n, m]}], {n, 1, 10, 1, Setter}, {{m, 1}, Range[1, n, 1], SetterBar}] To me it seems to be just a limitation to what kind of input syntax Manipulate is able to interpret correctly. Your {m, 1, n, 1, Setter} is correctly transformed into a SetterBar with a ...


3

Like this? Manipulate[ Row[ Plot[#[x]/x - c , {x, 0, 2 Pi}, ImageSize -> 300, PlotRange -> {{0, 7}, {-1, 1}}] & /@ {Sin, Cos}], {c, 0, 2}]


1

How about this? Expanding on John McGee's answer: Manipulate[ Plot[{Log[x], x/E} , {x, E - a, E + a} , PlotRange -> All , ImageSize -> 400 , ImagePadding -> {{50, 10}, {50, 10}}] , {a, E, E/100, -(E/100)} ] The ImagePadding is necessary in order to get rid of the annoying jitter that occurs when the axes labels change. PlotRange -> ...


4

Could you use PlotRange->{{e-w,1-h},{e+w,1+h}} Where w,h are the 1/2 width and 1/2 height of the zoom box?


0

myx1[t_] := Sin[t]; myx2[t_] := Sin[3 t]; myx3[t_] := Sin[4 t]; Manipulate[ Graphics[ { Circle[{myx1[t], 0}], If[t > 2, { {Red, Circle[{myx2[t], 0}, .5]}, {Green, Circle[{myx3[t], 0}, .5]} } ]}, PlotRange -> {{-2, 2}, {-2, 2}}], {t, 0, 10}]


3

Motivation In Mathematica most curves are ultimately rendered using Line, which has a straightforward derivative. Therefore it makes sense to create a function that solves the problem for the particular case of a Line object. For example pts = Flatten[Cases[Plot[Sin[x], {x, 0, 2 Pi}], Line[pts_] :> pts, Infinity], 1]; is the list of points which make ...


8

With your figure l1 = Line[{{0, 1}, {1, 1}}]; cir = Circle[{1, 0}, 1, {-π/2, π]/2}]; l2 = Line[{{0, -1}, {1, -1}}]; geom = {l1, cir, l2}; g = Graphics[geom]; and the rectangle marker l = 0; hw = 0.01; hh = 0.05; marker = Rasterize@Magnify[Graphics@Rectangle[{l - hw, hh}, {l + hw, -hh}], 0.07] one can create a binary image from the figure bg = ...


1

I think it's easier to create the counting clock by using Refresh without Clock: Manipulate[Graphics[{color, Rectangle[{-1, -1}/2, {1, 1}/2], White, Rectangle[{-1, -1}/4, {1, 1}/4], If[color === White, White, Black], Dynamic[Refresh[Text[If[Round[AbsoluteTime[] - refTime] > 30, refTime = AbsoluteTime[]]; Round[AbsoluteTime[] - ...


6

Some of this code is based on the last example of the docs on GradientOrientationFilter You can also smooth out the resulting path and reparametrize the interpolation based on the curve length to get a "constant velocity" displacement for the rectangle- l1 = Line[{{0, 1}, {1, 1}}]; cir = Circle[{1, 0}, 1, {-π/2, π/2}]; l2 = Line[{{0, -1}, {1, -1}}]; geom = ...


1

The root cause of the problem reported in the question was a bad formula. This led to a call to ArcCos that, with some arguments, produced a complex number as a result. When this value was given to any of the Region functions, an error resulted. The only way that I could find to debug the problem was traditional: isolate a failing case, working step by step ...


3

One can add the option Appearance -> "Labeled" to a Slider2D to have the current values shown as an editable label. Manipulate[ Graphics[{PointSize[Large], Point[p]}, PlotRange -> 1], {{p, {1, 1}}, {-1, -1}, {1, 1}, Appearance -> "Labeled"}] Using two 1D Slider Manipulate[ Graphics[{PointSize[Large], Point[{px, py}]}, PlotRange ...


1

What about the InputField: Manipulate[ Graphics[Point[p], PlotRange -> 1], {{p, {1, 1}}, Locator}, {p, {-1, -1}, {1, 1}, InputField}] ??


7

There are a lot of different ways to do this. My current favorite is Manipulate[{a, b}, {a, 1, 10}, {b, 1, 10, TrackingFunction -> (b = #; a = 10; &)}]


2

You can insert your Manipulate[...] in a DynamicModule[{lower,upper},...]: DynamicModule[{lower, upper}, Manipulate[ Refresh[ lower = distPlotRange[distribution, -1, 4]; upper = distPlotRange[distribution, 1, 4]; fillRange = {Max[#[[1]]], Min[#[[2]]]} &[ Transpose[{fillRange, {lower, upper}}]];, TrackedSymbols :> {distribution} ...


1

As I understand the OP's request, the following does what is desired. It may or may not be the best way to solve the actual problem, but I think it would help the OP pursue the approach in the question. Note one has to have the list of all the variables to be reset in the form Hold[a, b,...] Typing this by hand is perhaps easiest if there are only ...


2

One can localize the scope of variables to Manipulate by adding them as arguments to Manipulate with ControlType None. For your case Manipulate[Refresh[lower = distPlotRange[distribution, -1, 4]; upper = distPlotRange[distribution, 1, 4]; fillRange = {Max[#[[1]]], Min[#[[2]]]} &[ Transpose[{fillRange, {lower, upper}}]];, TrackedSymbols :> ...


3

The following much simpler Manipulate shows one way, how to get a label in Degree, while the variable value is in radian. Manipulate[x, Row[{Control[{{x, 0 Degree}, 0 Degree, 100 Degree}], Spacer[10], Dynamic[x/Degree], "\[Degree]"}]]


6

The option for a Manipulate control, that mimics the functionality of the second argument to Dynamic is TrackingFunction. f[x_] := Sin[x] Manipulate[ Column[{Show[Plot[f[x], {x, 0, 2 Pi}, Axes -> False, Frame -> True]], p}], {{p, {0, 0}}, Locator, TrackingFunction -> (p = {First@#, f@First@#}; &)}] Using only Manipulate and no ...


0

Ok, sorry, misunderstood the question, this should (more or less) work. Manipulate[ LocatorPane[Dynamic[pt], Plot[Sin[x], {x, 0, 20}, Epilog -> {Point[ Dynamic[{First[pt] + y, Sin[First[pt]] - Sin[y + \[Pi]/5] + 0.55}]]}], Appearance -> None], {y, -10, 10}] You may wish to specify the initial locator position for a slightly ...


4

You must use a Dynamic[] in your Manipulate[]. It is documented in the "Advanced Manipulate Tutorial" (chapter "Using Dynamic inside Manipulate") : solveDiffEq[a_] := { sol = NDSolve[ {f''[t] == a*f[t], f[0] == 1, f'[0] == 1}, f, {t, 0, 1}]; {AbsoluteTime[], f[t] /. sol[[1]]} }; Manipulate[ s = solveDiffEq[a0]; Dynamic[s /. t ...


3

Managing Manipulate and other Dynamic functionality is tricky. It takes some time reading the tutorials and experimenting to sort it all out. (There are four tutorials linked on the Manipulate page that introduce you to the complicated issues of Dynamic and Manipulate that anyone interested in solving such issues needs to read.) Even then you might still ...


3

Apart from szabolcs' dirty trick, a generic way to resolve this would be to precalculate one plot g=ContourPlot[f==0,{x,-5,5},{y,-5,5}]; And then use manipulate with the precalculated plot Manipulate[Show[g,Plot[m*x,{x,-5,5}]],{m,-5,5}]


2

Both styles are possible Row[{ Manipulate[ ContourPlot[ a[x, y] == 0, {x, -5, 5}, {y, -5, 5}], {{a, #1 - #2 &}}], Manipulate[ ContourPlot[ a == 0, {x, -5, 5}, {y, -5, 5}], {{a, x - y}}]} ] Edit Answering your comment below, you may use the function in many ways. Here I numerically solve a differential equation involving it: ...


4

Here's the basic idea, where you can adjust the function, limits, and Piecewise arguments for your specific case. Manipulate[ Plot[{120 - 50 x^2, 120 - 50 Sqrt[x]}, {x, 0, 1}, PlotRange -> {70, 120}, Filling -> {1 -> {2}}, PlotStyle -> {Green, Blue}, FillingStyle -> LightGray, Epilog -> {Red, PointSize[0.03], Point[{.5, ...


2

One can make c and a stepsize with an If statement interdependent controls of the Manipulate without showing stepsize. However, this only works after making the If statement Dynamic. f[x_] = Piecewise[{{-x, x < 0}, {x^2, x >= 0}}]; g[x_] = Piecewise[{{-1, x < 0}, {2 x, x > 0}}]; Manipulate[ Plot[{f[x], f[c] + g[c] (x - c)}, {x, -3, 3}, Epilog ...



Top 50 recent answers are included