How to interactively re-scale graphics with mouse?
- To: mathgroup at smc.vnet.net
- Subject: [mg117270] How to interactively re-scale graphics with mouse?
- From: James <icorone at hotmail.com>
- Date: Sun, 13 Mar 2011 05:27:47 -0500 (EST)
Hello guys, I'd like to draw a plot in manipulate, then click the right mouse button, drag the mouse while a red bounding box shows the area, then when I release the button, the plot is redrawn with that bounding box. Maybe there is a standard way to do this. Could someone let me know if so? Otherwise, I almost have it with a DynamicModule in the code below which captures the mouse locations and prints the coordinates as the title just for diagnostics, but I cannot figure out how to get the plot to redraw with those new coordinates and was hoping someone could look at it and give me some advise how to fix it. Thanks guys, \[Gamma]F[j_] := (j^2 - 1)/(j^2 + 1)^2; HopfF[TIn_, jIn_] := \[Gamma]F[jIn] - TIn; TuringF[DIn_, TIn_, jIn_] := DIn*(Sqrt[\[Gamma]F[jIn]] - Sqrt[TIn])^2; DynamicModule[{coord1 = {0, 1}, coord2 = {0, 1}}, EventHandler[ Dynamic[Show[{Plot[{HopfF[0.05, j], TuringF[8, 0.05, j]}, {j, 1, 5}, PlotRange -> {{1, 4}, {0.01, 0.3}}, PlotStyle -> {{Thickness[0.001], Black}, {Thickness[0.002], Red}}, Filling -> {{1 -> {{2}, {LightBlue, LightGreen}}}, {1 -> {Axis, LightRed}}, {2 -> {Top, LightYellow}}}, Frame -> True, PlotLabel -> {coord1, coord2}], Graphics[{EdgeForm[{Dashed, Red}], Red, Opacity[0], Rectangle[coord1, coord2]}]}]], {{"MouseDown", 2} :> (coord1 = MousePosition[ "Graphics"]), {"MouseUp", 2} :> (Null; coord2 = MousePosition["Graphics"]; )}, {"MouseDragged", 2} :> (Null; coord2 = MousePosition["Graphics"])]]