Re: options for VectorPlot in version 7 vs

• To: mathgroup at smc.vnet.net
• Subject: [mg104144] Re: options for VectorPlot in version 7 vs
• From: Dan Dubin <ddubin at ucsd.edu>
• Date: Wed, 21 Oct 2009 06:28:35 -0400 (EDT)
• References: <19419092.1255952174136.JavaMail.root@n11>

```Hi -- in David's fix the problem remains that unit vectors do not
"look" like unit vectors when the x and y scales are different. This
is solved in David's code by adding a scale factor to the unit
vectors that varies according to the direction of the unit vector:

f[x_, y_] = -.05 x + .0001 x y; g[x_, y_] = .1 y - .005 x y;

points = Flatten[Table[{x, y}, {x, -5, 75, 5}, {y, 0, 2500, 250}], 1];

arrow[{x_, y_}] :=
Arrow[{{x, y} -
2 Normalize[{f[x, y], g[x, y]}] Sqrt[f[x, y]^2 + g[x, y]^2]/
Max[10^-12, Sqrt[( f[x, y])^2 + ((90/2500) g[x, y])^2]], {x,
y} + 2 Normalize[{f[x, y], g[x, y]}] Sqrt[f[x, y]^2 + g[x, y]^2]/
Max[10^-12, Sqrt[( f[x, y])^2 + ((90/2500) g[x, y])^2]]}]

Graphics[{Arrowheads[.01], arrow /@ points}, AspectRatio -> 1,
PlotRange -> {{-10, 80}, {-200, 2700}}, Frame -> True]

The same scaling works in VectorPlot:

field = VectorPlot[{f[x, y], g[x, y]}, {x, 1, 70}, {y, 0, 2500},
PlotRange -> {{0, 70}, {0, 2500}}, VectorPoints -> {15, 15},
Frame -> True, AspectRatio -> 1,
VectorScale -> {.04, .04,
Sqrt[f[#1, #2]^2 + g[#1, #2]^2]/
Max[10^-12, Sqrt[(f[#1, #2])^2 + ((70/2500) g[#1, #2])^2]] &}]

>I'm sure WRI has a way, but it is very difficult to find a Help example that
>doesn't have the same x and y scale.
>
>If you don't get a better answer you could try something like this:
>
>points = Flatten[Table[{x, y}, {x, -5, 75, 5}, {y, 0, 2500, 250}], 1];
>
>arrow[{x_, y_}] :=
>  Arrow[{{x, y}, {x, y} + Normalize[{f[x, y], g[x, y]}]}]
>
>  AspectRatio -> 1,
>  PlotRange -> {{-10, 80}, {-200, 2700}},
>  Frame -> True]
>
>
>David Park
>djmpark at comcast.net
>http://home.comcast.net/~djmpark/
>
>
>
>
>
>
>From: janey [mailto:janemkiwi at gmail.com]
>
>Dear Mathematica Usenet Group,
>
>I have been having a lot of problems with finding appropriate options
>in Version 7 for VectorPlot that give an acceptable, viewable plot
>when scales on the horizontal and vertical axes are different (I am
>trying to get predator prey phase portraits, plotting population of
>predator vs population of prey; obviously there are far more prey than
>predators).
>
>My only solution so far has been to put up with the complaints from
>using
><< VectorFieldPlots`
>about the version 6 legacy version.
>
>For example, the following works just fine (apart from annoying
>warnings) in version 7 given that it uses the version 6 command
>VectorFieldPlot in place of version 7's VectorPlot:
>
><< VectorFieldPlots`;
>
>f[x_, y_] = -.05 x + .0001 x y; g[x_, y_] = .1 y - .005 x y;
>
>field = VectorFieldPlot[{f[x, y], g[x, y]}, {x, 1, 70}, {y, 0, 2400},
>   PlotPoints -> {15, 15}, Frame -> True, AspectRatio -> 1]
>
>With Version 7's VectorPlot, although I can specify the number of
>arrows to be shown with VectorPoints replacing PlotPoints, I have not
>been able to set VectorScale to give me anywhere near an acceptable
>plot.
>
>So  in version 7,
>
>f[x_, y_] = -.05 x + .0001 x y; g[x_, y_] = .1 y - .005 x y;
>
>field = VectorPlot[{f[x, y], g[x, y]}, {x, 1, 70}, {y, 0, 2400},
>   VectorPoints -> {15, 15}, Frame -> True, AspectRatio -> 1]
>
>
>Is there some source of information for manipulating these options
>somewhere besides the Mathematica Documentation Center's minimalist
>examples? If not, is anyone willing to share how to get success with
>this?
>
>
>thanks
>Janey.

--
---------------
| Professor Dan Dubin
| Dept of Physics , Mayer Hall Rm 3126,
| UC San Diego La Jolla CA 92093-0319
| phone (858) - 534-4174 fax: (858)-534-0173
| ddubin at ucsd.edu

```

• Prev by Date: Re: How to get data from solvin' numerically differential
• Next by Date: Re: Re: How to find which variable caused the trigger in Manipulate[]
• Previous by thread: Re: Re: Re: Suggestions on how to use standard engineering symbols
• Next by thread: DAE system