Problem with matshow and yticks: the rows of a matrix drawn by matshow does not have equal height

I had this problem but could not find the answer online. I will be highly appreciating if anyone can point me some direction on this problem.
I installed pythonxy and used matplotlib through ipython. I used matshow to draw a matrix and then set ticklables. This lead to the shown rows having uneven height. The following shows my problem:

fig1.png

fig2.png

···

import numpy
M=randn(4,6)
matshow(M)

This works fine and is shown in fig1.png. However, after I set the yticks:

yticks(arange(4), (‘1’,‘2’,‘3’,‘4’))


The rows of the matrix drawn have uneven height. Please see fig2.png.

Denzel Li, on 2011-02-01 15:34, wrote:

I had this problem but could not find the answer online. I will be highly
appreciating if anyone can point me some direction on this problem.
I installed pythonxy and used matplotlib through ipython. I used matshow to
draw a matrix and then set ticklables. This lead to the shown rows having
uneven height. The following shows my problem:
----------------------
import numpy
M=randn(4,6)
matshow(M)
-----------------------
This works fine and is shown in fig1.png. However, after I set the yticks:
------------------------
yticks(arange(4), ('1','2','3','4'))
---------------------------
The rows of the matrix drawn have uneven height. Please see fig2.png.

Hi Denzel,

what version of matplotlib are you using? I am unable to
reproduce on fairly recent checkout of svn trunk, so it may be an
issue that was recently fixed.

one workaround would be to set the ylim after the call to yticks,
like this:

  plt.ylim(3.5, -0.5)

best,

···

--
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

Hi Paul:
Thank you for you quick response.

I am using pythonxy 2.6.5.6. The matplotlib version is:
import matplotlib
print matplotlib.version
1.0.0
Do you mean the problem is fixed in matplotlib version 1.0.1? I will upgrade it and see how it works.

Your suggestion of ylim(3.5, -0.5) does work.

Thanks a lot.

Best,
Denzel

···

On Tue, Feb 1, 2011 at 4:42 PM, Paul Ivanov <pivanov314@…287…> wrote:

Denzel Li, on 2011-02-01 15:34, wrote:

I had this problem but could not find the answer online. I will be highly

appreciating if anyone can point me some direction on this problem.

I installed pythonxy and used matplotlib through ipython. I used matshow to

draw a matrix and then set ticklables. This lead to the shown rows having

uneven height. The following shows my problem:


import numpy

M=randn(4,6)

matshow(M)


This works fine and is shown in fig1.png. However, after I set the yticks:


yticks(arange(4), (‘1’,‘2’,‘3’,‘4’))


The rows of the matrix drawn have uneven height. Please see fig2.png.

Hi Denzel,

what version of matplotlib are you using? I am unable to

reproduce on fairly recent checkout of svn trunk, so it may be an

issue that was recently fixed.

one workaround would be to set the ylim after the call to yticks,

like this:

plt.ylim(3.5, -0.5)

best,

Paul Ivanov

314 address only used for lists, off-list direct email at:

http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

-----BEGIN PGP SIGNATURE-----

Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAk1Ifi0ACgkQe+cmRQ8+KPft6wCfRbaTT87V+S56AxwMIXK9HPvA

E8IAn1tl+ssa5puGREWoHlnAb0V3G4yv

=n6jX

-----END PGP SIGNATURE-----


Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!

Finally, a world-class log management solution at an even better price-free!

Download using promo code Free_Logger_4_Dev2Dev. Offer expires

February 28th, so secure your free ArcSight Logger TODAY!

http://p.sf.net/sfu/arcsight-sfd2d


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

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