xticks vs yticks

I’m having some problems understanding the difference between pylab.xticks() and pylab.yticks()
Consider the following:

import pylab as P
import numpy as N

data = N.random.random((10, 10))
P.matshow(data)
P.xticks([0, 1, 2], [‘1’, ‘2’, ‘3’])
P.show()

Why does this work, but if I change P.xticks to P.yticks, it doesn’t?

The error message that I get back doesn’t give me any insight as to what could cause the difference between xticks and yticks.

File “/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/figure.py”, line 612, in draw

for a in self.axes: a.draw(renderer)

File “/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/axes.py”, line 1287, in draw
self.transData.freeze() # eval the lazy objects

ValueError: Domain error on eval_scalars in Transformation::freeze

matplotlib.version
Out[2]: ‘0.90.1’

I am still in the learning phase, so any insight as to what’s going on is appreciated.

Best,
Jan

Sorry, reposting, because I sent it from the wrong address.

···

I’m having some problems understanding the difference between pylab.xticks() and pylab.yticks()
Consider the following:

import pylab as P
import numpy as N

data = N.random.random((10, 10))
P.matshow(data)
P.xticks([0, 1, 2], [‘1’, ‘2’, ‘3’])
P.show()

Why does this work, but if I change P.xticks to P.yticks, it doesn’t?

The error message that I get back doesn’t give me any insight as to what could cause the difference between xticks and yticks.

File “/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/figure.py”, line 612, in draw

for a in self.axes: a.draw(renderer)

File “/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/axes.py”, line 1287, in draw
self.transData.freeze() # eval the lazy objects

ValueError: Domain error on eval_scalars in Transformation::freeze

matplotlib.version
Out[2]: ‘0.90.1’

I am still in the learning phase, so any insight as to what’s going on is appreciated.

Best,
Jan


Jan Strube – University of Oregon
Stanford Linear Accelerator Center
Bldg. 48
phone: (650) 926-2913

Jan Strube wrote:

Sorry, reposting, because I sent it from the wrong address.

    I'm having some problems understanding the difference between
    pylab.xticks() and pylab.yticks()
    Consider the following:

        import pylab as P
        import numpy as N

        data = N.random.random((10, 10))
        P.matshow(data)
        P.xticks([0, 1, 2], ['1', '2', '3'])
        P.show()

    Why does this work, but if I change P.xticks to P.yticks, it doesn't?

This is now fixed in svn 3904. The problem was not related to x versus y but was caused by incorrect handling of the reversed y axis (positive down instead of positive up). If the x axis were the reversed one, the same problem would occur.

    The error message that I get back doesn't give me any insight as to
    what could cause the difference between xticks and yticks.

Yes, it is one of those infamous error messages from the extension code in the transforms module.

     File
    "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/figure.py",
    line 612, in draw
        for a in self.axes: a.draw(renderer)
      File
    "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/axes.py",
    line 1287, in draw
        self.transData.freeze() # eval the lazy objects
    ValueError: Domain error on eval_scalars in Transformation::freeze

It is probably a divide-by-zero error; but the real bug was elsewhere in the extension code, where the y-data-interval was erroneously set to zero when you tried to set the ticks.

     matplotlib.__version__
    Out[2]: '0.90.1'

    I am still in the learning phase, so any insight as to what's going
    on is appreciated.

    Best,
        Jan

Thanks for the good bug report, or more precisely, the good report of a bad bug.

I dimly recall some other email recently--maybe on matplotlib-devel--that may have been related. I think it was advocating a different method of keeping track of reversed axes. Maybe it was prompted by encountering the same problem you ran into.

Eric