Mouth position with the GraphicsRow
- To: mathgroup at smc.vnet.net
- Subject: [mg86517] Mouth position with the GraphicsRow
- From: Alexei Boulbitch <Alexei.Boulbitch at iee.lu>
- Date: Thu, 13 Mar 2008 04:29:30 -0500 (EST)
Dear MathGroup, could you help me with fixing the mouse position within a graphics, if several images are being shown in a row (or grid, etc.)? More precisely, I would like to place a locator within a graphics in such a way that it picks up the mouse position. The following works nicely. The first few lines define a graph (entitled pl), and the following combines it with the Locator Clear[g1, g2, x, pt]; g1[x_] := If[x <= 0, (3*x^2)/16, 0]; g2[x_] := If[x <= 0, x^2/4, 0]; pl = Plot[{g1[x], g2[x]}, {x, -4, 2}, PlotRange -> {{-4, 2}, {-2, 3}}, AxesLabel -> {b, a}, ImageSize -> 250]; DynamicModule[{pt = {1.7, 2}}, pt := Dynamic[MousePosition[{"Graphics", Graphics}, {1.7, 2}]]; Show[{pl, Graphics[Locator[pt]]}]] However, in another graph I need to show a polynomial whose coefficients a and b are picked from the locator position (i.e., from the mouse position within the first graph). As soon as I combine these two graphs as a GraphicsRow (or GraphicsColumn, etc.) the result is an error: DynamicModule[{pt = {1.7, 2}}, pt := Dynamic[MousePosition[{"Graphics", Graphics}, {1.7, 2}]]; GraphicsRow[{Show[{pl, Graphics[Locator[pt]] }], Dynamic[Plot[pt[[2]] x^2/2 + pt[[1]] x^4/4 + x^6/6, {x, -3, 3}, PlotRange -> {{-4, 4}, {-2, 3}}, Axes -> True, AxesLabel -> {x, "f"}, ImageSize -> 250] ] }] ] If the same combination is done with only the Locator (but without the MousePosition function) it also works nicely: Clear[g1, g2, x, pt]; g1[x_] := If[x <= 0, (3*x^2)/16, 0]; g2[x_] := If[x <= 0, x^2/4, 0]; pl = Plot[{g1[x], g2[x]}, {x, -4, 2}, PlotRange -> {{-4, 2}, {-2, 3}}, Axes -> True, AxesLabel -> {b, a},ImageSize -> 250]; DynamicModule[{pt = {1.7, 2}}, GraphicsRow[{Show[{pl, Graphics[Locator[Dynamic[pt]]]}], Dynamic[Plot[pt[[2]] x^2/2 + pt[[1]] x^4/4 + x^6/6, {x, -3, 3}, PlotRange -> {{-4, 4}, {-2, 3}}, Axes -> True, AxesLabel -> {"x", "f"}, ImageSize -> 250]]}]] Evidently, the problem is related to the MousePosition function. It is "confused" by the GraphicsRow. Can you give a hint, how to avoid the "confusion" when using the MousePosition with the combination of graphics? Thank you in advance, Alexei -- Alexei Boulbitch, Dr., habil. Senior Scientist IEE S.A. Material Development, ZAE Weiergewan 11, rue Edmond Reuter, L-5326 Contern, Luxembourg Tel.: +352 2454-2566 Fax: +352 2454-3566 e-mail: alexei.boulbitch at iee.lu -- This e-mail may contain trade secrets or privileged, undisclosed or otherwise confidential information. If you are not the intended recipient and have received this e-mail in error, you are hereby notified that any review, copying or distribution of it is strictly prohibited. Please inform us immediately and destroy the original transmittal from your system. Thank you for your co-operation.