Try something like below (there may be better ways to iterate over indices but the below is what I can think of now).
-JJ idxy, idxx = np.indices(tmat.shape) for ix, iy in zip(idxx.flat, idxy.flat): text(ix-0.5, iy+0.5, "%4.1f"%tmat[iy, ix], fontsize=12,color='b',name='serif') On Thu, Sep 24, 2009 at 3:34 AM, Bala subramanian <bala.biophys...@gmail.com> wrote: > Friends, > > I have a matrix which i plotted with matshow as follows and then used text > function to write the each value inside the figure by choosing x and y > coordinate. I wish to know if there is any easy or more fancy way to do the > same. > > mat=load('tnz.txt') > In [3]: tmat=transpose(mat) > In [4]: tmat > Out[4]: > array([[ 10.2 , 26.4 , 12.2 , 13.6 , 24.6 , 13.9 , 10.2 , 20.6 , > 17. , 14.9 , 24.2 , 13. ], > [ 13.6 , 26.2 , 10.5 , 13.6 , 26.8 , 9.87, 11. , 23.1 , > 14.7 , 16.7 , 25.3 , 15.6 ], > [ 10.7 , 22.4 , 6. , 11.8 , 23.8 , 7.4 , 6.7 , 20.9 , > 10.3 , 12.5 , 20.9 , 7.9 ]]) > In [5]: matshow(tmat,cmap=cm.autumn) > Out[5]: <matplotlib.image.AxesImage object at 0x9a2c7cc> > > Now i wanted to give the show the values in the matrix using the text > function as follows > > > In [8]: text(-.489,.511,'10.2',fontsize=12,color='b',name='serif') > Out[8]: <matplotlib.text.Text object at 0x9a41e2c> > > In [9]: text(.495,.511,'26.4',fontsize=12,color='b',name='serif') > Out[9]: <matplotlib.text.Text object at 0x9a489ac> > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® 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/devconf > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > ------------------------------------------------------------------------------ Come build with us! The BlackBerry® 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/devconf _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users