Plot a matrix in one command?

View: New views
3 Messages — Rating Filter:   Alert me  

Plot a matrix in one command?

by Piter_ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 :(

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@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Re: Plot a matrix in one command?

by Scott Sinclair-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>2009/10/27 Piter_ <x.piter@...>:
> 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

------------------------------------------------------------------------------
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@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Re: Plot a matrix in one command?

by Gökhan SEVER-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



2009/10/27 Piter_ <x.piter@...>
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 :(

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@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users




--
Gökhan

------------------------------------------------------------------------------
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@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users