0
$\begingroup$

I have some data that requires selection using arbitrary thresholds, which is easiest done by eye. So I have set up a dynamic plot with two locator points for selecting the region I want.

data={{{1.73679,1.91168},{1.55538,1.54084},{1.37184,1.16632},{1.10972,0.635937},{0.891606,0.212788},{0.70264,-0.210078},{1.74121,0.454819},{1.56004,0.0588364},{1.37662,-0.317372},{1.10284,-0.86595},{0.888137,-1.40797},{0.701468,-2.34178},{1.73287,0.988477},{1.5572,0.646471},{1.37561,0.32348},{1.10565,-0.163553},{0.888739,-0.516153},{0.702386,-0.871263},{1.7417,1.40016},{1.55489,1.03389},{1.37827,0.665655},{1.11066,0.132673},{0.895207,-0.309524},{0.70009,-0.73737}},{{1.61492,1.5848},{1.45069,1.24408},{1.27261,0.879649},{1.00738,0.35819},{0.775678,-0.132106},{0.601168,-0.486675},{1.65163,0.119725},{1.47888,-0.246092},{1.30125,-0.528595},{1.02634,-0.962473},{0.800255,-1.30977},{0.611253,-2.64814},{1.628,0.623475},{1.44684,0.324816},{1.27031,0.0220086},{0.983139,-0.365573},{0.756034,-0.63744},{0.558382,-0.969921},{1.59567,0.918655},{1.41399,0.565877},{1.21975,0.197553},{0.957237,-0.349699},{0.73963,-0.782909},{0.547884,-1.1475}}};
pos=(MinMax/@Flatten[data,{{3},{1,2}}])\[Transpose];
DynamicModule[{pts=pos},Grid[{{ListAnimate[Function[x,LocatorPane[Dynamic[pts],Dynamic[Show[ListPlot[{data[[x]],pts},PlotStyle->{Black,Opacity[0]},PlotRange->All,ImageSize->350],Plot[2(z-#[[1]])+#[[2]]&@Median[data[[x]]],Join[{z},MinMax[data[[x,All,1]]]],PlotStyle->Red,PlotRange->All],Graphics[{Opacity[0.1],Rectangle@@(pts)}]]]]]/@Range[Length[data]],AnimationRunning->False,DisplayAllSteps->True]},{Button["Finished",t=pts]}}]]

Which outputs a plot like:

Dynamic plot of data

Clicking the Finished button saves the current Locator Points as t, for example:

t = {{0.765,-2.02},{1.477,1.36}}

The trouble is that I need to run a bunch of later computations, and my computer is a bit too slow with this dynamic processes continuing to update after saving the thresholds, however I can't seem to find a "disable dynamic updates function". I tried doing something with TrackedSymbols, which I didn't like as part of the ease was using the LocatorPane, which doesn't seem to update then.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.