Bug - ylims are reversed

I can’t figure out sourceforge’s interface
to submit a ticket, so I’m mailing this to the devel list. That’ll
give you a sense of my urgency ;- )

Version: 0.98.3

when calling get_xlims(), the values
returned are in increasing order: [xmin, xmax]. With get_ylims()
however, it is reversed.

make axes in figure, named ax

ax.get_xlims()

[-5, 639]

ax.get_ylims()

[479.5, -0.5]

ax.set_ylims(ymin, ymax) seems to work,
until you use the Image artist. The image flips upside down when
you do this.

I first noticed it when I called ax.imshow(image)
and an image was right side up. When I called set_ylims(ymin, ymax),
it flipped upside down. It was rightside up if I called set_ylims(ymax,
ymin)

Workaround: simply reverse the limits
when using set_lims or get_lims

Affected:

Images

Axes

Axes documentation (where get_ylims
is described as get_ylims(ymin, ymax) )

Sorry for not sending this to the right
place,

-Conrad Ammon

···

Subject: Axes Ylims are reversed

Conrad B Ammon wrote:

I can't figure out sourceforge's interface to submit a ticket, so I'm mailing this to the devel list. That'll give you a sense of my urgency ;- )

Subject: Axes Ylims are reversed
Version: 0.98.3

when calling get_xlims(), the values returned are in increasing order: [xmin, xmax]. With get_ylims() however, it is reversed.
# make axes in figure, named ax

ax.get_xlims()
>> [-5, 639]
ax.get_ylims()
>> [479.5, -0.5]

ax.set_ylims(ymin, ymax) seems to work, until you use the Image artist. The image flips upside down when you do this.

I first noticed it when I called ax.imshow(image) and an image was right side up. When I called set_ylims(ymin, ymax), it flipped upside down. It was rightside up if I called set_ylims(ymax, ymin)

Workaround: simply reverse the limits when using set_lims or get_lims

Affected:
Images
Axes
Axes documentation (where get_ylims is described as get_ylims(ymin, ymax) )

Sorry for not sending this to the right place,
-Conrad Ammon

Conrad,

It is just as well to start out with a mailing list in a case like this.

What you have found is a very confusing aspect of the variable naming and the documentation, not a bug in the code itself. It has always been part of the mpl design that set_ylim and set_xlim are really setting the bottom and top values, and the left and right values, in that order, and not the min and max.

To compound the confusion, images are inverted by default; row number increases from top to bottom.

See also the methods invert_yaxis, set_ybound, etc.

Eric