imshow y axis question

Yes, that is exactly what I meant. For now I am doing the following when
using matshow():

xa, xl = pylab.xticks()
pylab.xticks(xa + 0.5, [str(int(a)) for a in xa])
ya, yl = pylab.xticks()
pylab.yticks(ya + 0.5, [str(int(a)) for a in ya])

which shifts the ticks to the centre from the left edge. In cases where
the last tick falls at far edge of the plot, I modify the above with
xa[:-1]+0.5 and ya[:-1]+0.5 as needed for each axis.

The above code does raise another question. Originally, I tried

xa, xl = pylab.xticks()
pylab.xticks(xa+0.5, xl)

but I received a type error for the xl argument:

   File "/usr/lib64/python2.4/site-packages/matplotlib/", line 671, in set_text
     raise TypeError("This doesn't look like a string: '%s'"%s)
TypeError: This doesn't look like a string: '<matplotlib.text.TextWithDash instance at 0x2aaaaac9afc8>'

This error is received when the plot is rendered after a call to Why doesn't the object returned from pylab.xticks() work when you send it back to itself as an argument? Seems weird, especially since there is no problem with pylab.xticks(xa, xl) accepting it.



On Thu, 1 Mar 2007, Eric Firing wrote:

I agree, and this is a problem with spy also. If I remember, I will fix it.
It is only a minor annoyance, so it is low priority, though.

There is a difference in the way the axes are labeled between spy and
matshow, and I would like to change matshow to agree with spy, unless there
is an outcry to the contrary. Specifically, I think the integer axis ticks
should land in the middle of a given row or column, not on the edge. To see
what I mean, compare

xx = zeros((3,3))
xx[1,1] = 1
spy(xx, marker='s')

Maybe this is exactly what you mean by your next statement?

> Further, I would think a setting like align='center' in would
> be appropriate. Any simple way of doing this without manually setting > the
> ticks and labels (ironically using forced *.5 ticks)?