Tag Info

7

This is a very common problem for people who work on data analysis. Here as a solution to the problem using LocatorPane and a few other functions and tricks. TooltipListPlot[data_, tipFunction_, listPlotOptions___] := DynamicModule[ {displayQ = False, yRange , xRange, pt, minX, maxX, minY, maxY, tip, threshold, tipPosition, nf, dataPoints, ...

6

Here's one solution that meets the criterions. I'll walk through the main ideas step by step. First I started by creating a list of circles and a list of lines. Then I formed a region from those elements, which I called grid. I also added the gridlines that were used originally and so recreated the plot: circles = Table[Circle[{0, 0}, r], {r, 1, 14}]; ...

5

Edit: This is a rewrite. The original answer was more or less an extended comment containing some seemingly relevant clues. I've tracked down two probable issues, each related to a system variable, and there may be others. At least in either case, the crashing can be triggered or prevented.* It turns out that Dynamic@RegionPlot[..] depends on the ...

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 = ...

4

This can be done more cleanly by localizing curve to the manipulate, which in turn is done by making curve an invisible control. This also obviates the need for the Initialization option, because controls take optional initializers. Manipulate[ Graphics[{ {Red, PointSize @ .02, Point@pt}, Line @ AppendTo[curve, pt]}, Axes -> True, ...

4

An alternative approach using CurrentValue["MouseOver"]: Button[Panel["Print", FrameMargins -> {{4, 4}, {4, 4}}, Background -> Dynamic@If[CurrentValue["MouseOver"], Green, Red]], Print["Print"], Appearance -> None]

3

Here is some code to get you started. I say "started" because this isn't a fool-proof solution. For one thing, it doesn't provide a way to retract a segment should the user make an bad drag. There are also some refresh issues to be dealt with. A full solution will a fair amount of additional work, and I don't have time to work it out right now. cnt[p_] := ...

3

Another method which doesn't really use Mouseover but the EventHandler: DynamicModule[{col = Red}, EventHandler[ Button[ Panel["Print", FrameMargins -> {{4, 4}, {4, 4}}, Background -> Dynamic[col]], ...

3

The Plot has to be within Dynamic, as the Plot needs to be updated when z is changed. You can't just update the content of Plot without making a new Plot. {Slider[Dynamic[z], {1, 4, 1}], Dynamic@Plot[Evaluate[Table[Sin[i*t], {i, 1, z}]], {t, 0, 2 Pi}]} The syntax highlighting is due to the Head of your command inside Plot being Dynamic ...

3

The x and y of the ContourPlot are interfering with the x and y inside of Dynamic. If you use for example ContourPlot[Total[Log[Clip[b-a.{x2,y2},{10^-10,\[Infinity]}]]],{x2,-2,2},{y2,-2,2},PlotRange->{-10,0}] it'll not crash. I guess this shouldn't be necessary.

3

Fundamental problem Pardon me if I miss some points of your question as I didn't attempt to understand what your code is intended to do, because I think I understand what the problem is from the title alone. Please consider: SetAttributes[f, {HoldFirst, Listable}]; f[x_] := foo[x] f[{1, 2, 3}] {foo[1], foo[2], foo[3]} bar = {1, 2, 3}; f[bar] ...

3

When a Symbol is "tracked" it means that when its value changes the Dynamic expression is refreshed, therefore your input updates as fast as possible because every refresh changes the value of t which causes a refresh which... you get the picture. Compare: Clear[t]; t = 1; Dynamic[Refresh[t++, UpdateInterval -> 1, TrackedSymbols -> {}]]

2

simple version With a single codeline, ColorData["Atoms", "Panel"], can be transformed in a click panel for ElementData[]. {ColorData["Atoms", "Panel"] // ReplaceAll[#, RuleDelayed[ "MouseClicked", $_] :> (RuleDelayed["MouseClicked", atomClicked = Part[RuleDelayed["MouseClicked",$], 2, 2, 2, 1, 1, 1]])] &, Dynamic[atomClicked, Initialization :> ...

2

The more general solution to this problem is to make use of the Option SynchronousUpdating->False: pts=Flatten[Table[Through[{Cos,Sin}[\[Alpha]]] r,{\[Alpha],0.,360 \[Degree]-10^-5,60 \[Degree]},{r,1,2}],1]; LocatorPane[Dynamic[pts], Dynamic[Show[ Graphics[{Arrow /@ Partition[pts, 2]}], {a, b} = Transpose[Map[Module[{p1, p2, d}, {p1, p2} = #; ...

2

Replacing the Set in Initialization by a SetDelayed solved the problem, TrackedSymbols should be set also. Conjecture: It seems Clear before Manipulate produces problems, I can't believe it. It can be used in a separate cell, but not in the same cell. Experiences? Manipulate[ curve = Append[curve, pt]; Graphics[{{Red, PointSize@.02, Point@pt}, ...

2

Pardon me if this is unjustifiably curt but I don't see how this problem is different from many others that result from placing Dynamic too deep within an expression. Move the Dynamic to the outside and the element in question updates just fine: on = True; Row@{Checkbox@Dynamic@on, Spacer@10, ExpressionCell[ Dynamic@RawBoxes@ RowBox@{"Block", ...

2

The last three locals are actually String, i.e. "\"local\"" at the box level. The fourth from the end, however, should be due to lacking of syntax highlight at the FrontEnd. For this problem, I guess you'll have to force the FrontEnd re-render the ExpressionCell after each update of the on. Usually this can be done by changing an option of the cell (like ...

1

There are lots of ways to do what you want. I would not use Module. Here are three, all of which use methods other than Module to localize variables: SeedRandom @ 42; With[{rand = RandomInteger[10, {5, 5, 2}]}, Manipulate[ ListPlot[rand[[i]], PlotRange -> {{-1, 11}, {-1, 11}}], {i, 1, Length[rand], 1, Appearance -> "Labeled"}]] SeedRandom @ ...

1

if you need to keep the definition of l inside manipulate, I think you can try this Manipulate[l = RandomInteger[10, {3, 5, 2}]; ListPlot[l[[i]], PlotRange -> {{-1, 11}, {-1, 11}}], {i, 1, Dynamic@Length@l, 1}] you need to know that for every i, l will be computed again and again. if you want to do 3 plot per each l then you can do it like this ...

1

I classify your question as "Serious" thus, here is my answer. In many cases I have found myself in situations where a "canonical solution" does not seem to exist for a given problem found while creating Mathematica solutions. In those cases I tend to create a reasonable enough solution. When I read your question I remembered that a couple of years ago I ...

1

From tutorial/InteractiveGraphicsPalette you can see that quite a few of the lowercase keys are used by DrawingTools which becomes active once the cursor focus is on the graphics. So, the easiest work-around is to use uppercase letters in your EventHandler as suggested by pjc42. When the first argument of EventHandler does not contain a graphics object, ...

1

another idea but not an answer... DynamicModule[{keyList = {}, pts = {}, input = Null}, EventHandler[ {LocatorPane[Dynamic[pts], Graphics[Circle[], ImageSize -> 500], LocatorAutoCreate -> True, Appearance -> {Graphics[{Red, Disk[]}, ImageSize -> 10], Graphics[{Blue, Disk[]}, ImageSize -> 10]} (*LocatorPane**)], ...

1

This is only a partial answer but may help. See here for related case, it is probable that KeyDown "a" is reserved like "c". This does not work: DynamicModule[{someList = {}}, EventHandler[Graphics[{Blue, Disk[]}, ImageSize -> 100], {{"KeyDown", "a"} :> (AppendTo[someList, 1]; Print[someList])}]] (** doesn't work **) But changing "a" to ...

1

Refresh only sets a limit on how long expression can go without being updated. To keep t form being updated more often add a pause. t = 1; Dynamic[Refresh[Pause[1]; t++, UpdateInterval -> 1, TrackedSymbols :> {t}]] or do what Mr.Wizard indicated, which is better. But this sort of thing is best done by higher level constructs such as Clock or ...

1

I found an answer to my own question by reading the answer to Make dynamic controls from existing list. So I guess the answer to my question is to define the functions internally in the dynamic module with the HoldFist attribute. DynamicModule[{controlGenerate, ruleslist = ruleslist, ruleslist2 = ruleslist2, result, controlfromList}, ...

1

The example below shows the effects of forcing a unitary step size in the manipulator in the application you created. The table is filled as expected but there is an uncomfortable lag in the manipulator. I created this example to support the following statements. I think that Manipulator really doesn't need a new option but that programmers need to adjust ...

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