       Re: Inserting a position-limited Locator inside a Manipulate multiplot

• To: mathgroup at smc.vnet.net
• Subject: [mg107184] Re: Inserting a position-limited Locator inside a Manipulate multiplot
• From: dh <dh at metrohm.com>
• Date: Fri, 5 Feb 2010 03:20:31 -0500 (EST)
• References: <hkeapc\$svc\$1@smc.vnet.net>

```Hi Adrian,
as an example, I put a locator on the first curve:

f0[a_, x_] := Sin[3 a x] + x;
f[a_] := Plot[f0[a, x], {x, -5, 7}];
g[a_, b_] := Plot[Cos[a x] b, {x, -5, 7}];
DynamicModule[{p = {0, 0}},
Manipulate[
loc := Locator[Dynamic[p, (p = {#[], f0[a, #[] ]} ) &]];
txt = Text[Style["y=" <> ToString[p[]], 20], Scaled[{0.6, 0.1}]];
Show[{
f[a], g[a, b],
Graphics[{  loc, txt } ]
}], {a, -4, 4}, {b, {0, 1}, ControlType -> Checkbox}]]

Daniel

> Hello,
>
> First of all, i apologize if the question i post has been posted
> before... I tried to find an applicable message but could not. of
> course my own lack of experience in anything but basic mathematica
> functions doesn't help.
>
> My original reason for this project was that i am learning to graph the
> behavior of acid-base reactions in human blood. To do this, we are
> given titration plots where we plot a solution with only a strong acid
> and another one with a strong acid and a weak acid. To those of you not
> familiar with such plots, they are useful in determining the ion
> difference (or equivalence point) for a solution, which can tell you
> much about its acid dissociation constant and other important traits.
> If I am successful in implementing this, i would move on to Log-Log
> plots of similar behavior, but that would not be much harder if i solve
> this problem.
>
> =========The Problem=========
>
> The plot i wanted to make in Mathematica 7 was where i could compare
> both behaviors on the same graph (titration plots), so I began by
> creating a basic Manipulate Sin(x) plot just to get an idea of the
> concept as once i get that, plugging in my functions should be child's
> play. There are 3 things i want in the final product:
>
> 1. both plots should be modifiable (which i can do)
> 2. the main plot can persist, but additional ones (some graphs will
> have up to 4 plots) should be able to be removed with a checkbox (i did
> this with a bit of success)
> 3. each plot should have a locator that is constrained to follow the
> plot and return the values for the plot (this was the kicker for me)
>
> of the three goals, i was able to do #1 & #2 two plots, though i'm not
> sure if i can generalize to three or four plots as i want. The hardest
> for me has been to integrage locators into the plots, but this is also
> the most important. why? because many times the interesting behavior of
> these plots is in areas that are hard to read. I have made Manipulate
> plots before that zoom in, so that helps, but perhaps im still in love
> with the old TI 89 ability to trace a plot (sorry).
>
> anyways, here is one attempt i made:
> (*this plot was my first successful combination of two functions. i
> want to keep my functions malleable so that i can play with them or
> modify them as i need. i now need to insert a locator that will trace
> them*) f[a_, x_] := Plot[{Sin[3 a x] + x}, {x, -5, 7}]; g[a_, x_, b_]
> := Plot[Cos[a x] b, {x, -5, 7}]; DynamicModule[{x = x}, Manipulate[Show[{f[a, x], g[a, x, b]}], {a, -4, 4}, {b, {0, 1}, ControlType ->
> Checkbox}]]
>
> =======Extra Info==========
>
> I tried many times to insert a locator, but failed, the following are
> two examples of my failed attempts:
> (*I had made a few attempts at sticking a LocatorPane in the equations
> but sticking it inside a DynamicModule and sticking everything else
> in it failed, sticking it inside Manipulate failed, part of the
> failure was the fact my Locator required an argument from the
> function, but there is no clear way to give it an argument, so im
> going to begin from scratch on inventing a single function where i
> can stick a locator and get its info on position and also limit its
> movement*)Manipulate[Plot[Sin[x], {x, -2 , 2 }], {{p, {0, 0}},
> Locator}]
>
> this second attempt was where i was able to update its position... i
> think in an earlier attempt it actually worked, but didn't now that i
> tried to move it again:
> (*this was my first successful integration of the Locator in a plot
> along with updating the position of the locator via the PlotLabel.
> its not the best solution because you usually want a title for the
> plot label, but this is a start*)DynamicModule[{p = {2, 1}},
> Manipulate[Plot[{2 Sin[x]}, {x, -2 , 2 }, PlotLabel -> Dynamic[p],
>  Epilog -> Locator[Dynamic[p, (p = Normalize[#]) &]]]]]
>
>
> sorry for so much info, but i thought it might help outline my
> limitations. I would truly appreciate any help in this issue...
> particularly with #3
>
>
> --
> I always welcome email at my address if you are a friend and not a
> spammer. With that in mind, the first time you email me, you will be
> met by my spam filter. Don't let it put you off, a quick response to my
> spam filter will get your message through!
>
>

```

• Prev by Date: Re: Localize Pattern variables
• Next by Date: Re: Localize Pattern variables
• Previous by thread: Inserting a position-limited Locator inside a Manipulate multiplot
• Next by thread: Re: Inserting a position-limited Locator inside a Manipulate multiplot