## matplotlib-users

 [Matplotlib-users] plotting a matrix vs a vector From: Ryan Krauss - 2005-05-14 19:50:48 ```
Is there a quick and easy way to plot the columns of a matrix versus a vector and get different color lines for each column?  If I try

In [50]: shape(timevector)
Out[50]: (21001, 1)

In [51]: shape(datamatrix)
Out[51]: (21001, 3)

In [52]: plot(timevector,datamatrix)
I get:
RuntimeError: xdata and ydata must be the same length

In matlab, this would give me 3 diffent color lines, one for each column of datamatrix.

plot(timevector,datamatrix[:,i]) works just fine for one line

Do I need to define a matrix plotting function like

def matrixplot(xvect,ymat):
ioff()
for i in range(shape(ymat)[1]):
plot(xvect,ymat[:,i])
show()
ion()

or is there an easier/faster way?

Ryan

```
 Re: [Matplotlib-users] plotting a matrix vs a vector From: John Hunter - 2005-05-16 14:08:24 ```>>>>> "Ryan" == Ryan Krauss writes: Ryan> Is there a quick and easy way to plot the columns of a Ryan> matrix versus a vector and get different color lines for Ryan> each column? You can build a color list and cycle through it with a counter, as described in the recent thread "Plotting of multiple spectras" on the mailing list. Eg colors = ("b", "g", "r", "c", "m", "y", "k") ind = 1 while ind < 18: Y = take(X,(0,ind), 1) x = Y[:,0] y = Y[:,1] plot(x,y,"-"+colors[ind % len(colors)]) ind = ind + 2 Ryan> line Do I need to define a matrix plotting function like def Ryan> matrixplot(xvect,ymat): ioff() for i in Ryan> range(shape(ymat)[1]): plot(xvect,ymat[:,i]) show() ion() or Ryan> is there an easier/faster way? Ryan Yes, this is one area in which the mpl plot function differs from matlab. There is a faster way, using line collections. This difference in speed would be considerable for a large number of lines. See examples/line_collections.py in matplotlib CVS. JDH ```
 [Matplotlib-users] OS X 10.4 pylab broke From: Graeme O'Keefe - 2005-05-17 13:54:22 ```I have just upgraded to OS X 10.4 on two machines. On one machine, pylab worked fine, on my notebook it hangs. I have begun trying to rebuild my fink tree but bomb at glib 2.6.2 / gtk+, pango-1.8.0 using fink as well as standalone installs for old items (pango is at 1.6 on fink, need 1.8 for gtk+2.6.0). As an aside, numarray install bombed with gcc4.0 so I had to revert to gcc3.3. Anyone else had problems with OS X 10.4 and pylab? regards, Graeme ```
 Re: [Matplotlib-users] OS X 10.4 pylab broke From: Graeme O'Keefe - 2005-05-17 23:23:27 ```Hi Jeff, yes, I did (fink-0.23.9.tar.gz install, ./bootstrap.sh etc. all went well and I was able to re-install emacs which had also broken with the 10.4 upgrade.) I shall await 10.4 upgrades. In the interim, http://pythonmac.org/packages/matplotlib-0.72.1-py2.3-macosx10.3.zip http://pythonmac.org/packages/numarray-1.1.1-py2.3-macosx10.3.zip http://pythonmac.org/packages/TigerPython23Compat.pkg.zip (fixes up site-packages location) have allowed me to get pylab imported, now I just need to get a backend compiled (gtk is my preferred backend). thanks, Graeme On 18/05/2005, at 12:06 AM, Jeff Whitaker wrote: > Graeme O'Keefe wrote: > > >> I have just upgraded to OS X 10.4 on two machines. On one >> machine, pylab worked fine, on my notebook it hangs. I have begun >> trying to rebuild my fink tree but bomb at glib 2.6.2 / gtk+, >> pango-1.8.0 using fink as well as standalone installs for old >> items (pango is at 1.6 on fink, need 1.8 for gtk+2.6.0). >> >> As an aside, numarray install bombed with gcc4.0 so I had to >> revert to gcc3.3. >> >> Anyone else had problems with OS X 10.4 and pylab? >> >> regards, >> >> Graeme >> >> >> >> >> > Graeme: Did you follow the instructions for upgrading fink for > 10.4 on the fink home page? It's a tricky upgrade - many (if not > all) packages need to rebuilt. Many packages are not yet working, > since many developers (like me) don't yet have 10.4. > > -Jeff > > > -- > Jeffrey S. Whitaker Phone : (303)497-6313 > NOAA/OAR/CDC R/CDC1 FAX : (303)497-6449 > 325 Broadway Web : http://www.cdc.noaa.gov/~jsw > Boulder, CO, USA 80305-3328 Office: Skaggs Research Cntr 1D-124 > > ```