Re: ListPlot with row vectors
- To: mathgroup at smc.vnet.net
- Subject: [mg28510] Re: ListPlot with row vectors
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Tue, 24 Apr 2001 01:48:47 -0400 (EDT)
- References: <9bvvbd$3s7@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Nicola,
> I have 2xN matrix whose column vectors are points in the cartesian plane.
I
> would like to plot these points, and therefore I assumed that ListPlot
would
> do the job. But I realized that ListPlot only plots a one row vector
against
> integer numbers, or at the most a list of points in the form
> {{x1,y1},{x2,y2},{}...}
> The problem is that I have the points in the form
> A={{x1,x2,x3,x4,x5,x6...},{y1,y2,y3,y4,y5}}.
> How can I turn my matrix into a form that Mathematica can use, so to plot
> the points on the plane?
A = {{2,1, 1, 1, 2, 1}, {0, 0, 1, 3, 0, 1}}
{{2, 1, 1, 1, 2, 1}, {0, 0, 1, 3, 0, 1}}
A1=Transpose[A]
{{2, 0}, {1, 0}, {1, 1}, {1, 3}, {2, 0}, {1, 1}}
> One more questions, if you don't mind. How can I have the starting matrix
A
> contain only unique points? In other words, there should be no repetitions
> of the same point in the matrix.
If you only want to plot the points then theire order is not important, so
you can use
A2= Union[A1]
{{1, 0}, {1, 1}, {1, 3}, {2, 0}}
To remove repeats withou altering the order we can use Carl Woll's
technique:
RemoveRepeats[x_List]:=Block[{i},i[n_]:=(i[n]=Sequence[]; n); i/@x];
A3= RemoveRepeats[A1]
{{2, 0}, {1, 0}, {1, 1}, {1, 3}}
--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565
"Nicola" <pasquino at seas.upenn.edu> wrote in message
news:9bvvbd$3s7 at smc.vnet.net...
> I have 2xN matrix whose column vectors are points in the cartesian plane.
I
> would like to plot these points, and therefore I assumed that ListPlot
would
> do the job. But I realized that ListPlot only plots a one row vector
against
> integer numbers, or at the most a list of points in the form
> {{x1,y1},{x2,y2},{}...}
> The problem is that I have the points in the form
> A={{x1,x2,x3,x4,x5,x6...},{y1,y2,y3,y4,y5}}.
> How can I turn my matrix into a form that Mathematica can use, so to plot
> the points on the plane?
>
> One more questions, if you don't mind. How can I have the starting matrix
A
> contain only unique points? In other words, there should be no repetitions
> of the same point in the matrix.
>
> Please *post* and *email* your replies.
> Thanks for your help!
>
> Nicola
>
>
>