tick locations in new matshow()

The new matshow() seems to like ticks every 4 units (or multiples of 4 for larger scales) rather than the normal, more desirable every 5 units.

Compare:

import pylab
matrix = pylab.rand(30,30)
pylab.matshow(matrix)
pylab.show()

with

import pylab
matrix = pylab.rand(30,30)
pylab.imshow(matrix)
pylab.show()

Looking at the code right now, but since matshow() calls imshow(), it is not obvious to me. I presume it has something to do with the line

ax = fig.add_axes([0.15, 0.09, 0.775, 0.775])

in matshow(). Still learning the internals of mpl ...

Also, as mentioned in a previous thread, the new matshow() is missing tick marks on the lower x-axis.

Cheers,
Suresh

Suresh Pillai wrote:

The new matshow() seems to like ticks every 4 units (or multiples of 4 for larger scales) rather than the normal, more desirable every 5 units.

Compare:

import pylab
matrix = pylab.rand(30,30)
pylab.matshow(matrix)
pylab.show()

with

import pylab
matrix = pylab.rand(30,30)
pylab.imshow(matrix)
pylab.show()

Looking at the code right now, but since matshow() calls imshow(), it is not obvious to me. I presume it has something to do with the line

ax = fig.add_axes([0.15, 0.09, 0.775, 0.775])

No, this determines where in the figure window the axes will be located.

in matshow(). Still learning the internals of mpl ...

It is a question of the tick locator that is used.

imshow is using the default MaxNLocator, which generally does a nice job but will sometimes put ticks on non-integer locations. Therefore, for matshow, I added a kwarg to guarantee use of integer locations. I should be able to tweak it so that its results differ from the default MaxNLocator only when the latter would produce non-integers. That was the intention.

Also, as mentioned in a previous thread, the new matshow() is missing tick marks on the lower x-axis.

I thought I fixed that in svn, but it looks like I was foiled by a bug somewhere in axis.py. I'll have to track it down. To be continued...

Eric

ยทยทยท

Cheers,
Suresh