Plot a matrix in one command?

Hi all.
I have a matrix M:
First column is X ans the rest are Ys. Lets say 100 of them (1000 sometimes).
So far I can plot it like
plot(M(:,1), M(:,2),M(:,1),M(:,3)… and so on and so on)
Is there any possibility to do it in matlab way? Like:

plot(M(:,1),M(:,2:end))

This is main thing stopping me from migration from matlab to Python now :frowning:

Thanks.
Petro.

2009/10/27 Piter_ <x.piter@...287...>:
I have a matrix M:
First column is X ans the rest are Ys. Lets say 100 of them (1000
sometimes).
So far I can plot it like
plot(M(:,1), M(:,2),M(:,1),M(:,3)... and so on and so on)
Is there any possibility to do it in matlab way? Like:

plot(M(:,1),M(:,2:end))

Hi Piter,

Does the following do what you want?

import numpy as np
import matplotlib.pyplot as plt
x = np.arange(10)
y = np.random.random((10, 5))
M = np.column_stack((x, y))
plt.plot(M[:, 0], M[:, 1:])
plt.show()

Python indices start from zero, Matlab indices start from 1.

Cheers,
Scott

2009/10/27 Piter_ <x.piter@…287…>

Hi all.
I have a matrix M:
First column is X ans the rest are Ys. Lets say 100 of them (1000 sometimes).
So far I can plot it like
plot(M(:,1), M(:,2),M(:,1),M(:,3)… and so on and so on)
Is there any possibility to do it in matlab way? Like:

You can’t index arrays with regular parentheses in Python. How do you distinguish function calls from array-matrix indexing in Matlab?

···

plot(M(:,1),M(:,2:end))

This is main thing stopping me from migration from matlab to Python now :frowning:

Thanks.
Petro.


Come build with us! The BlackBerry(R) Developer Conference in SF, CA

is the only developer event you need to attend this year. Jumpstart your

developing skills, take BlackBerry mobile applications to market and stay

ahead of the curve. Join us from November 9 - 12, 2009. Register now!

http://p.sf.net/sfu/devconference


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

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


Gökhan