MathGroup Archive 2007

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

Search the Archive

Re: plotting vectors

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83926] Re: [mg83869] plotting vectors
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Tue, 4 Dec 2007 04:33:21 -0500 (EST)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <200712031044.FAA18885@smc.vnet.net>
  • Reply-to: murray at math.umass.edu

Which version of Mathematica are you using?

What did you try -- what documentation did you read in order to prepare 
to do this.

Do you know how to plot the data if you already have it in the form of a 
list of {xi,yi} pairs?  In the Mathematica 6 Documentation Center, you 
would look under the heading Visualization and Graphics and click the 
link Data Visualization.  You discover you want to use ListPlot.

Probably you already know that much.  And from the { } notation you're 
using, it seems you know that lists are involved.  Your problem is:  how 
to change a pair {x,y} of lists x={x1, x2, ..., xn} and y={y1, y2, ..., 
yn} into the list { {x1,y1}, {x2,y2}, ..., {xn,yn} } of 2-element lists. 
  So in the Mathematica 6 Documentation Center, under the heading Core 
Language click Lists (or in the search bar type Lists).  You'll get the 
guide page List Manipulation, and the third header there is likely the 
one you want: Rearranging & Restructuring Lists.  If you know the 
corresponding mathematical term "transpose", or just by searching 
through the various functions there, you'll come upon Transpose.  That's 
what you need.

For example:

   x = Table[Random[Integer, {0, 100}], {20}];
   y = Table[Random[Real, {0, 1}], {20}];

   ListPlot[Transpose[{x, y}]]

Of course you may embellish the plot by coloring or enlarging the 
points, etc.  For example:

   ListPlot[Transpose[{x, y}], PlotStyle -> {Red, PointSize[Large]}]

I hope this helps, and I apologize if I assumed you know less about 
Mathematica than I thought.  But I wanted to guide you into discovering 
for  yourself answers to questions such as you asked.

fcs04001 wrote:
> Suppose that I have two vectors x and y, each with 72 elements. I want to plot them, but not have to type {x1,y1},{x2,y2},...etc for all 72 pairs. Is there an easy way to do that? I know that in another system this is pretty easy, but am having difficulty with Mathematica to perform that.
> Thanks.
> 

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


  • Prev by Date: Re: different eigenvectors
  • Next by Date: Re: FindInstance what inspite ?
  • Previous by thread: plotting vectors
  • Next by thread: Re: plotting vectors