Tag Info

New answers tagged

0

Maybe this is also an acceptable approach depending on your needs. asd=1; {Slider[Dynamic[asd, (asd = If[# <= 10, #, Round@#]) &], {1, 50}], Dynamic@asd}


2

The \[Alpha] used ouside of the Manipulate is not the same as the \[Alpha] inside of the Manipulate (scoping). Parameterize f to make the variables identical. Excessive PlotPoints slows the plotting. Clear[f, \[Alpha]] n = 0; h = 1; H = (x^2 + p^2)/2; f[\[Alpha]_, x_, p_] = (1/Pi)*(-1)^n*Exp[-2*H/h]*LaguerreL[n, 4 H/h] - (2/3)*\[Alpha]*p^3* ...


2

You just need to put in conditions that test whether the point crosses the curve. You'll need to keep track of the previous position. You'll also need to decide what constitutes a crossing. The simplest is that it changes sides (as indicated by the y coordinate) when the x coordinates of the point and the previous point are within the plot's domain (for ...


1

Perhaps I'm missing something, but can't this problem be solved without the event handling? Manipulate[ LogPlot[Log[T], {T, 273.16, 647.096}, PlotStyle -> Thick, Epilog -> Inset[Style[Text[If[Exp@Last@l > Log[First@l], "Vapor", "Liquid"]], 16, Bold], l, Scaled[{-.5, 1}]]], {{l, {450, Log[5.6]}}, Locator}] I'll edit to include ...


1

You don't want to pass the full data set into the Manipulate. You just want to pass its name and have it evaluated inside the Manipulate. Try the following. Is it fast enough? SeedRandom[42]; data = RandomReal[{0, 1}, {500, 500, 500}]; SetAttributes[vizData, HoldFirst]; vizData[dataVar_Symbol] := Manipulate[Image[dataVar[[All, All, i]]], {i, 1, 500, 1}] ...


4

shape1 := Graphics[{#, Circle[{0, 0}, 1.5], Disk[]}, ImageSize -> 10] &; shape2 := Graphics[{Lighter@#, Disk[]}, ImageSize -> 10] &; ClearAll[lOF]; lOF[nOfOverlays_, colors_List, opts : OptionsPattern[]] := DynamicModule[{layer = 1, pts = ConstantArray[{{100, 100}, {700, 700}}, nOfOverlays], col = ...


0

You should define your functions outside of the Manipulate so the definitions aren't reevaluated each time the slider is moved. In doing this, you'll need to make g and U explicitly depend on ρ. g[e_, ρ_] := { {e, ρ, 11}, {1, e, ρ}, {1, 1, e} }; U[e_, ρ_] := Transpose[Eigenvectors[g[e, ρ]]] . { {0, 0, 1}, {0, 1, 0}, {1, 0, 0} }; Next it ...


0

I would suggest: Try to write your function definition outside of the Manipulate, but in dependence of the changing parameter, like so: g[ρ_, e_] := ( {{e, ρ, 11}, {1, e, ρ}, {1, 1, e}} ); U[ρ_, e_] := (Transpose[Eigenvectors[g[ρ, e]]]).( { {0, 0, 1}, {0, , 0}, {1, 0, 0}} ); And than inside the Manipulate use this function definition: Manipulate[ ...


0

I have updated the code so that now it is able to create a stack of locator overlays on an image of interest (here a simple Circle[] but I am overlaying the locators on Colorized WatershedComponents matrices resulting from microscopy images of cells) and I have also dispensed with the Manipulate and replaced it with a function with a DynamicModule. However, ...


1

I used 3 rather than 6 functions for each plot and used a Frame rather than Axes to reduce the clutter. f := RandomReal[]; h := Floor[f*20]; When the Table is inside of the Plot use Evaluate Manipulate[ Plot[ Evaluate[ Table[f Sin[h x + h t], {3}]], {x, -5, 5}, PlotRange -> {-1.1, 1.1}, Frame -> True, Axes -> False], {{t, 5}, 0, ...


4

EDIT As Mr Wizard observed my original code is not self contained. For reasons that I fail to understand this seemed to work with what seemed a fresh session. The code works if you move the gauge marker but to post correct code (I leave the animated gif as it is the same outcome): DynamicModule[{s = 0}, Framed[Row[{VerticalGauge[Dynamic[s], {0, 1}, ...


1

I believe the jump in value of asd happens because you're dragging the indicator with the mouse when the range is reset. Here is a way that does what you want, I think. It interrupts the mouse-dragging by creating a new Slider when the boundary is reached. {Dynamic@asd, Dynamic@Slider[Dynamic[asd], Which[asd < 10, {1, 10}, asd >= 10, {9, 50, ...


1

This functions: params[a] = 5; params[b] = 6; Manipulate[params[a] = n, {n, 10, 100, 1}] In contrast: c = 1; Manipulate[c, {c, 10, 100, 1}] Here, the Manipulate displays the change of the local c. It doesn't change the global c which still has value 1.


1

Using the logManipulator from my answer to Logarithmic slider, you can also achieve your objective via Manipulate[ f[x, y], {x, 10.^-10, 10^-1, 10, logManipulator[##] &}, {y, 0.01, 1, 0.01}] Code for logManipulator: ClearAll[logManipulator]; With[{smallerRule = {Large -> Medium, Medium -> Small, Small -> Tiny}}, ...


1

f[x_, y_] = x*y; Manipulate[ f[x, y] // ScientificForm, {{x, 10.^-6}, 10.^Range[-1, -10, -1]}, {{y, .5}, 0.01, 1, 0.01, Appearance -> "Labeled"}]


1

A few alternatives: Using SmoothHistogram: Manipulate[ Module[{data = RandomVariate[BinomialDistribution[n, p], 500]}, Show[Plot[PDF[BinomialDistribution[n, p], x], {x, 0, 20}, PlotRange -> {{-.5, 21.5}, {-.1, 1}}, Evaluated -> True, PlotStyle -> Directive[Thick, Blue], Epilog -> {PointSize[0.03], ...


0

Yes, one way is to use Tuples again after some judicious partitioning: Tuples[Partition[Tuples[{{"USD", "EUR", "JPY"}, {"UP", "DOWN"}}], 2]] Note the 2 is the length of the second set in the original Tuples so you could write your own function: myTuples[list1_List, list2_List] := Tuples[Partition[Tuples[{list1, list2}], Length[list2]]]


2

Here is one way: Tuples@Outer[List, {USD, EUR, JPY}, {UP, DOWN}] (* {{{USD, UP}, {EUR, UP}, {JPY, UP}}, {{USD, UP}, {EUR, UP}, {JPY, DOWN}}, {{USD, UP}, {EUR, DOWN}, {JPY, UP}}, {{USD, UP}, {EUR, DOWN}, {JPY, DOWN}}, {{USD, DOWN}, {EUR, UP}, {JPY, UP}}, {{USD, DOWN}, {EUR, UP}, {JPY, DOWN}}, {{USD, DOWN}, {EUR, DOWN}, {JPY, UP}}, ...


1

Use value -> label in the list of values: Manipulate[ plot[[n]], {plot, {rawplots -> "foo", weightplots -> "bar", linearizedplots -> "baz"}, PopupMenu} ]


3

For the first question the problem is only in the radius of the small circle. it should be like this: Circle[center[{R, r}, θ], r]


0

f[h_] := Which[h < a, 1 - 1.5 h/a + 0.5 (h/a)^3, h >= a, 0]; With[{g = f[h]}, Manipulate[Plot[g, {h, 0, 8}], {a, 5, 10}]] also f[h_] := Which[h < a, 1 - 1.5 h/a + 0.5 (h/a)^3, h >= a, 0]; Manipulate[Plot[f[h] /. a -> b, {h, 0, 8}], {b, 5, 10}]


1

It looks like you're trying to overlay some plots (up to 500). Are you sure this is what you want to do? Regardless, this code works fine in Mathematica 10.0. somegraphs = Table[Plot[x^ii, {x, 0, ii}], {ii, 1, 100}]; Manipulate[Timing[Show[somegraphs[[1 ;; ii]]]], {ii, 1, 100, 1}] Perhaps you'll need to show more code.


1

You could use Dynamic to update i: graphComponents = {{"blood", "pressur"}, {"harvard", "oxford"}, {"help", "lower"}, {"oxford", "benefit"}, {"harvard", "benefit"}, {"lower", "level"}, {"faceoff", "benefit"}, {"oxford", "faceoff"}, {"harvard", "faceoff"}, {"over", "benefit"}, {"faceoff", "over"}, {"oxford", "over"}, {"harvard", ...


2

Is this what you want? graphComponents = {{"blood", "pressur"}, {"harvard", "oxford"}, {"help", "lower"}, {"oxford", "benefit"}, {"harvard", "benefit"}, {"lower", "level"}, {"faceoff", "benefit"}, {"oxford", "faceoff"}, {"harvard", "faceoff"}, {"over", "benefit"}, {"faceoff", "over"}, {"oxford", "over"}, {"harvard", "over"}, {"benefit", ...


0

Using Bill's answer but adding Epilog[] for labeling, try f1[x_] := x^2; f2[x_] := x^4; Manipulate[ Plot[{f1[x + n], f2[x + n]}, {x, 0.0001, 1}, PlotStyle -> {Red, Blue}, PlotRange -> {-10, 10}, Epilog -> { (Text[ Style["f1", FontFamily -> "Times New Roman", FontSize -> 10, Red], {.6, f1[n + .6] + .6}]), (Text[ ...


5

If you are using version 10 you can make use of the new Indexed function: expr1 = Array[Indexed[a, {##}] &, {3, 2}] If you are on an older version you can Quiet the error messages and use: expr2 = Quiet @ Array[a[[##]] &, {3, 2}] {{a[[1, 1]], a[[1, 2]]}, {a[[2, 1]], a[[2, 2]]}, {a[[3, 1]], a[[3, 2]]}} With either expression, if a is ...


6

You can do this with Inactive like this temp = Array[Inactive[Part][a, #1, #2] &, {3, 2}]; you can then set an a at a later stage and Activate that: a = RandomReal[{-1, 1}, {4, 4}]; Activate[temp]


0

Manipulate[ Show[ Plot[x^2 + a + b + c, {x, 0, 2}], ListPlot[{{0, 0}, {1, 1}, {2, 2}}], PlotRange -> {-5, 5}], {a, -1, 1}, {b, -1, 1}, {c, -1, 1}]


1

Here is an answer that pretty much sums up the advice you got in the comments made to your question. Manipulate[ Dynamic @ Show[ Plot[f[x], {x, 0, 2}], ListPlot[{{0, 0}, {1, 1}, {2, 2}}, PlotStyle -> Red, PlotMarkers -> {Automatic, Small}], PlotRange -> {Automatic, {-3, 7}}, AxesOrigin -> {0, 0}], {{a, 0}, -1, 1}, ...


2

In Mathematica 10, we can use Graph3D: Graph3D@RandomGraph[{20, 50}]


1

It depends on what you mean by size. PlotRange will "zoom", ImageSize produces larger graphic. For illustration: Manipulate[ ContourPlot[ x^4 + y^4 + 2*x^2*y^2 - x^2 + y^2 == n, {x, -r, r}, {y, -r, r}, ImageSize -> imagesize], {n, -.2, 3}, {r, Range[2, 5]}, {imagesize, Range[200, 500, 100]}]


0

PlotRange is the answer: Manipulate[ ContourPlot[ x^4 + y^4 + 2*x^2*y^2 - x^2 + y^2 == n, {x, -5, 5}, {y, -5, 5}, PlotRange -> {{-1.2, 1.2}, {-1.2, 1.2}} ], {n, -.2, 3}] Try also PlotRange -> All and PlotRange -> Automatic EDIT: You can also do kind of a zoom with Manipulate[] Manipulate[ ContourPlot[ x^4 + y^4 + 2*x^2*y^2 - x^2 ...


1

Manipulate[ Plot[{Sin@x, Normal@Series[Sin@u, {u, x0, n}] /. u -> x}, {x, -2 Pi, 2 Pi}, PlotRange -> {Automatic, {-2, 2}}, Epilog -> {PointSize[Medium], Point@{x0, Sin@x0}}], {n, 0, 10, 1}, {x0, -Pi, Pi}]


5

Perhaps this? Manipulate[ {names, slide, setter, cases}, Dynamic@Switch[cases, "custom", Control[{{names, True}, {True, False}}], "a", Control[{{slide, 0}, 0, 1}], "b", Control[{{setter, "das"}, {"das", "der", "die"}}]], {{cases, "custom"}, {"custom", "a", "b"}}] The variables seem to get localized properly even though the syntax ...


3

Something like that? list = Range[0, 9]; DynamicModule[{nr, val}, Column[{ Dynamic@list, Dynamic@list[[ nr]], Slider[Dynamic@nr, {1, 10, 1}], Slider[Dynamic[list[[ nr]]], {0, 10, 1}] }] ] Manipulate version: list = Range[0, 9]; Manipulate[ Column[{list, list[[nr]]}], Column[{ Control[{{nr, 1}, 1, 10, 1}], ...


1

If you are just asking how to reproduce your code more compactly/parametrically, you can use RandomInteger to produce a list of integers then rearrange. For now let's just use n = 5. We can generate the rules by creating two long lists and then threading them together. Here's the list of left-hand sides (of the rules): nodes = Sort@Flatten@Table[Range@8, ...


1

ddata = First@ToExpression@Import[ "http://pastebin.com/raw.php?i=KwJSvA2r", "Data"]; ddata = ddata /. {a_, b_} -> {a + 1.5, b}; backgraound = ListPlot[ddata, PlotRange -> {{-2, 5}, {0, 500}}, AxesOrigin -> {-2, 0}] Manipulate[ Show[{backgraound, Plot[r (c k (x - a)^(-1 + c) (1 + (x - a)^c)^-j), {x, 0, 5}]}, PlotRange -> ...


1

Like this? ddata = First@ToExpression@Import["http://pastebin.com/raw.php?i=KwJSvA2r", "Data"]; points = ListPlot[ddata, PlotRange -> {{-5, 5}, {0, 100}}, Axes -> True]; Manipulate[ Show[points, Plot[c*k*(x^(c - 1))/((1 + x^c)^(j)), {x, 0, 50}, PlotStyle -> Red, PlotRange -> {{0, 5}, {0, 100}}]], {c, 0, 10}, {k, 0, 10}, {j, 0, 5}]



Top 50 recent answers are included