MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: PlotVectorField

  • To: mathgroup at
  • Subject: [mg34819] Re: PlotVectorField
  • From: shollis at (Selwyn Hollis)
  • Date: Sat, 8 Jun 2002 05:21:34 -0400 (EDT)
  • References: <adpg01$j55$>
  • Sender: owner-wri-mathgroup at

I guess my original question was a bit cryptic, but Wolf's reply got
me thinking in the right direction. Actually what I was trying to do
was to overlay a vector field with several curves created with
ListPlot. The points given to ListPlot typically spill out beyond the
rectangle on which I want to plot, so I needed so way to restrict the
plot to the desired rectangle. PlotRange is the obvious way, but it
leads to the difficulties I was trying to describe.

Anyway, I wonder what you all think about the following fix: Instead
of using PlotRange, I apply a ``pullback" function to the list of
points to make sure they all lie in the rectangle I want before I give
the list to ListPlot. The only points in the list that can possibly
spill out of the rectangle are the first and the last. So I made the
following functions for each edge of the rectangle a<=x<=b, c<=y<=d.
Each one just replaces the first/last point in the list with a convex
combination of first two/last two points in such a way that the result
is on the edge of the rectangle.

pulla[z_,a_]:= Module[{r=(z[[1,1]]-a)/(z[[1,1]]-z[[2,1]])},
    ReplacePart[z, r*z[[2]]+(1-r)*z[[1]], 1]];
pullb[z_,b_]:= Module[{r=(z[[-1,1]]-b)/(z[[-1,1]]-z[[-2,1]])},
    ReplacePart[z, r*z[[-2]]+(1-r)*z[[-1]], -1]];
pullc[z_,c_]:= Module[{r=(z[[1,2]]-c)/(z[[1,2]]-z[[2,2]])},
    ReplacePart[z, r*z[[2]]+(1-r)*z[[1]], 1]];
pulld[z_,d_]:= Module[{r=(z[[-1,2]]-d)/(z[[-1,2]]-z[[-2,2]])},
    ReplacePart[z, r*z[[-2]]+(1-r)*z[[-1]], -1]];

Then I put everything together like this:

Now, pullback[pointlist, {a,b,c,d}] gives points that all lie in the
desired rectangle and still accurately produce the curve.

If anyone has an ideas as to how this pullback function can be written
is a more ``MC" (Mathematica-ly Correct) way, I'd appreciate your


  • Prev by Date: Re: Is it possible to access internal variables?
  • Next by Date: Re: puzzling difference in speed
  • Previous by thread: RE: PlotVectorField
  • Next by thread: RE: Re: PlotVectorField