Re: tweaking VectorPlot...

• To: mathgroup at smc.vnet.net
• Subject: [mg111317] Re: tweaking VectorPlot...
• From: Jae Bum Jung <jaebum at wolfram.com>
• Date: Tue, 27 Jul 2010 04:18:20 -0400 (EDT)

```  There's undocumented option (like "RightArrow", "LeftArrow") you can
use in VectorStyle.  For example,

points={{-1,-1},{-1,1},{1,-1},{1,1}};VectorPlot[{-1-x^2+y,1+x-y^2},{x,-2,2},{y,-2,2},VectorPoints->points,VectorScale->.25,Epilog->{Red,PointSize[Medium],Point[points]},
VectorStyle->"LeftArrow"]

or

Show[{dp,
VectorPlot[f, {x, -3, 3}, {y, -3, 3}, VectorPoints -> pts,
VectorScale -> {.15, .2},

Just make sure these are undocumented, i.e., it's subject to be changed
in the future version of Mathematica.

- Jaebum

On 7/26/10 5:36 AM, Patrick Scheibe wrote:
> Hi,
>
> this is far away from being *clean*: Take a potential and calculate the
> gradient. Combine DensityPlot and ContourPlot (or
> LineIntegralConvolution with vectorlength coloring if you like) on the
> potential. If it's an artificial student-example use an easy potential
> which you solve explicitely in one variable. So you can choose your
> points on the wanted level and use VectorPlot to visualize the vectors
> only on the curve.
>
> For the tails of the arrows I have no better idea then replacing:
>
> <<  VectorAnalysis`
> pot = x^2 + x y - Sin[y^2]
> f = -Most@Grad[pot, Cartesian[x, y, z]]
>
> dp = Show[{DensityPlot[pot, {x, -3, 3}, {y, -3, 3},
>      ColorFunction ->  "TemperatureMap"],
>     ContourPlot[pot == 0.2, {x, -3, 3}, {y, -3, 3},
>      ContourStyle ->  {Thick, Black}]}];
>
> ys = Table[y, {y, -4, 4, 6/40.}];
> sol = Solve[pot == 2/10, x];
> pts = Flatten[Table[{x, y} /. sol, {y, ys}], 1];
>
> vp = VectorPlot[f, {x, -3, 3}, {y, -3, 3}, VectorPoints ->  pts,
>     VectorScale ->  0.25, VectorStyle ->  {Black, Arrowheads[0.02]}] /.
>    Arrow[{p1_, p2_}] :>  Arrow[{p1 + (p2 - p1)/2, p2}];
>
> Show[{dp, vp}]
>
> Hope this gives you a starting point.
>
> Cheers
> Patrick
>
> On Sun, 2010-07-25 at 01:57 -0400, J Davis wrote:
>> Looking at this example in the documentation...
>>
>> points = {{-1, -1}, {-1, 1}, {1, -1}, {1, 1}}; VectorPlot[{-1 - x^2 +
>>     y, 1 + x - y^2}, {x, -2, 2}, {y, -2, 2}, VectorPoints ->  points,
>>   VectorScale ->  .25,
>>   Epilog ->  {Red, PointSize[Medium], Point[points]}]
>>
>> I would prefer for the *tail* of the vector to be situated at "points"
>> rather than the tip (or as Mathematica draws them, the base of the
>>
>> I was hoping there was an option I could call to VectorPlot to make
>> the desired behavior happen but I don't find any.
>>
>> Suggestions? Or do I need to manually translate all the vectors? I was
>> hoping to avoid that since students would be utilizing the code and I
>> want to keep it as clean and simple as possible.
>>
>> Once I accomplish the task above, I was looking for a clean way to
>> plot the level curves of a surface and then superimpose the gradient
>> vector field---but here's the catch---where the only vectors shown
>> were the ones along the level curves (meaning their *tails* are along
>> the level curves). I tried RegionFunction but didn't get satisfactory
>> results.
>>
>> Any help is appreciated.
>>
>> Thanks,
>> John
>>
>>
>

```

• Prev by Date: Re: Linking my fortran subroutines with Mathematica
• Next by Date: Re: Linking my fortran subroutines with Mathematica
• Previous by thread: Re: tweaking VectorPlot...
• Next by thread: Prediction Bands and Confidence Intervals