2
$\begingroup$

The code below creates a StreamPlot for a nonlinear system of first-order ODEs:

$\dot{x}=y,\dot{y}=x+\tfrac{1}{4}x^{2}$

I have created a simple zoom slider that expands the region about the critical point at $(x,y)=(0,0)$. In order to zoom about the other critical point at $(x,y)=(−4,0)$, I have written the system with a translation of $(x_0,y_0)$ to $(0,0)$. Unfortunately the location of the Ticks do not shift accordingly. In particular, by translating the point $(x,y)=(−4,0)$ to $(x,y)=(0,0)$, I want the $x$ Tick to be -4 instead of 0 and center the StreamPlot at $(x_0,y_0)$. Can the Ticks be translated accordingly? Translating the $u$ and $v$ intervals by $x_0$ and $y_0$ respectively doesn't do it.

Manipulate[ StreamPlot[{v + y0, (u + x0) + 1/4 (u + x0)^2}, {u, -r, r}, {v, -r, r}, StreamScale -> Automatic, AspectRatio -> 1, ImageSize -> 500, FrameLabel -> {x, y}, RotateLabel -> False, LabelStyle -> Directive[FontFamily -> "Helvetica", 14], StreamPoints -> Fine, Epilog -> {{Red, PointSize[0.01],Point[{{-x0, -y0}, {-4 - x0, -y0}}]}}], {{x0, 0, "x center"}, -6, 6, .01}, {{y0, 0, "y center"}, -6, 6, .01}, {{r, 6, "zoom"}, 6, 0.01, .01}, Button["Reset", {x0 = 0, y0 = 0, r = 6}] ] 
$\endgroup$
2
  • $\begingroup$ Move 'x0' from '(u+x0)' to the plot range '{x,-r+x0,r+x0}' in your 'StreamPlot'. Also, you can't define your points in terms of 'x0', 'y0' since those two values just represent a shift of the axes, so your points should be at '{0,0}', and '{-4,0}' $\endgroup$ Commented May 5, 2016 at 14:17
  • 1
    $\begingroup$ That did it! I thought that I had tried your fix, but obviously I must have coded it incorrectly. $\endgroup$ Commented May 5, 2016 at 14:26

1 Answer 1

2
$\begingroup$

You should change the variable ranges, rather than translate the function; The points you are interested in are at a fixed position in the original frame, so don't move then either:

Manipulate[ StreamPlot[ {v, (u) + 1/4 (u)^2}, {u, -r + x0, r + x0}, {v, -r + y0, r + y0}, StreamScale -> Automatic, AspectRatio -> 1, ImageSize -> 500, FrameLabel -> {x, y}, RotateLabel -> False, LabelStyle -> Directive[FontFamily -> "Helvetica", 14], StreamPoints -> Fine, Epilog -> {Red, PointSize[0.01], Point[{{0, 0}, {-4, 0}}]} ], {{x0, 0, "x center"}, -6, 6, .01}, {{y0, 0, "y center"}, -6, 6, .01}, {{r, 6, "zoom"}, 6, 0.01, .01}, Button["Reset", {x0 = 0, y0 = 0, r = 6}] ] 
$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.