plots points corresponding to a list of values - similar to listplot of mathematica

Hello,
Is there a way?Like the title says?
I have a 2d list :

[[ 0 1]
[ 1 1]
[ 1 0]
[ 2 0]
[ 1 0]
[ 2 0]
[ 1 0]
[ 0 0]
[ 1 0]
[ 1 -1]]

and i want to do the "listplot' from mathematica.

Thanks!

I don’t know of a plot function to do this, but one extra line of code should suffice:

pts = [[0, 1],
[1, 1],
[1, 0],

[2, 0],
[1, 0],
[2, 0],
[1, 0],
[0, 0],
[1, 0],
[1,-1]]

x, y = np.transpose(pts)
plt.plot(x, y)

Best,
-Tony

···

On Sun, Nov 6, 2011 at 8:20 AM, Gousios George <ggeo1@…713…830…> wrote:

Hello,

Is there a way?Like the title says?

I have a 2d list :

[[ 0 1]

[ 1 1]

[ 1 0]

[ 2 0]

[ 1 0]

[ 2 0]

[ 1 0]

[ 0 0]

[ 1 0]

[ 1 -1]]

and i want to do the "listplot’ from mathematica.

You can also do

x,y = zip(*pts)

If you don’t feel like importing numpy.

Ben

···

On Sun, Nov 6, 2011 at 12:49 PM, Tony Yu <tsyu80@…287…> wrote:

On Sun, Nov 6, 2011 at 8:20 AM, Gousios George <ggeo1@…3830…> wrote:

Hello,

Is there a way?Like the title says?

I have a 2d list :

[[ 0 1]

[ 1 1]

[ 1 0]

[ 2 0]

[ 1 0]

[ 2 0]

[ 1 0]

[ 0 0]

[ 1 0]

[ 1 -1]]

and i want to do the "listplot’ from mathematica.

I don’t know of a plot function to do this, but one extra line of code should suffice:

pts = [[0, 1],
[1, 1],

[1, 0],

[2, 0],
[1, 0],
[2, 0],
[1, 0],
[0, 0],
[1, 0],
[1,-1]]

x, y = np.transpose(pts)
plt.plot(x, y)

Best,
-Tony


RSA® Conference 2012

Save $700 by Nov 18

Register now

http://p.sf.net/sfu/rsa-sfdev2dev1


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users