Setting y-tick locations on an image plot changes y-axis limits, Bug or expected behavior?

Hi,

I’ve recently noticed that setting the y-tick locations on an image plot changes the y-axis limits, while changing the x-tick locations does not change the x-axis limits. I wouldn’t have expected either to change the axis limits, but it seems quite inconsistent that the y-axis and x-axis behave differently in this situation.

The axis limits are easily restored by a call to “ax.axis(‘image’)”, but this seems unnecessary.

A very quick search of the bug tracker doesn’t reveal anything matching this description…

Is this expected behavior or a bug?

As an example, setting the y-tick locations changes the y-axis limits:

import numpy as np

import matplotlib.pyplot as plt

num = 10

data = np.arange(num**2).reshape((num,num))

fig = plt.figure()

ax = fig.add_subplot(111)

cax = ax.imshow(data)

ax.set_yticks(range(num//2))

fig.show()

However, setting the x-tick locations does not change the axis limits…
import numpy as np
import matplotlib.pyplot as plt

num = 10
data = np.arange(num**2).reshape((num,num))

fig = plt.figure()
ax = fig.add_subplot(111)

cax = ax.imshow(data)

ax.set_xticks(range(num//2))

fig.show()

As a reference, I’m running matplotlib 1.0.0 with python 2.7.0 on a 64-bit Linux (kernel 2.6.31) machine. I can confirm this on python 2.6 and matplotlib 0.99 as well, though.

If this isn’t expected behavior, I’ll be glad to open a bug report.

Thanks!
-Joe

···

Hi,

I've recently noticed that setting the y-tick locations on an image plot
changes the y-axis limits, while changing the x-tick locations does not
change the x-axis limits. I wouldn't have expected either to change the
axis limits, but it seems quite inconsistent that the y-axis and x-axis
behave differently in this situation.

The axis limits are easily restored by a call to "ax.axis('image')", but
this seems unnecessary.

A very quick search of the bug tracker doesn't reveal anything matching
this description...

Is this expected behavior or a bug?

As an example, setting the y-tick locations changes the y-axis limits:
import numpy as np
import matplotlib.pyplot as plt

num = 10
data = np.arange(num**2).reshape((num,num))

fig = plt.figure()
ax = fig.add_subplot(111)

cax = ax.imshow(data)

ax.set_yticks(range(num//2))

fig.show()

However, setting the x-tick locations does not change the axis limits...
import numpy as np
import matplotlib.pyplot as plt

num = 10
data = np.arange(num**2).reshape((num,num))

fig = plt.figure()
ax = fig.add_subplot(111)

cax = ax.imshow(data)

ax.set_xticks(range(num//2))

fig.show()

As a reference, I'm running matplotlib 1.0.0 with python 2.7.0 on a
64-bit Linux (kernel 2.6.31) machine. I can confirm this on python 2.6
and matplotlib 0.99 as well, though.

If this isn't expected behavior, I'll be glad to open a bug report.

It's a bug. I think I have it fixed, but I need to do some more testing, so I won't commit anything tonight.

Eric

···

On 08/20/2010 12:18 PM, Joe Kington wrote:

Thanks!
-Joe

------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hi,

I've recently noticed that setting the y-tick locations on an image plot
changes the y-axis limits, while changing the x-tick locations does not
change the x-axis limits. I wouldn't have expected either to change the
axis limits, but it seems quite inconsistent that the y-axis and x-axis
behave differently in this situation.

The axis limits are easily restored by a call to "ax.axis('image')", but
this seems unnecessary.

A very quick search of the bug tracker doesn't reveal anything matching
this description...

Is this expected behavior or a bug?

As an example, setting the y-tick locations changes the y-axis limits:
import numpy as np
import matplotlib.pyplot as plt

num = 10
data = np.arange(num**2).reshape((num,num))

fig = plt.figure()
ax = fig.add_subplot(111)

cax = ax.imshow(data)

ax.set_yticks(range(num//2))

fig.show()

However, setting the x-tick locations does not change the axis limits...
import numpy as np
import matplotlib.pyplot as plt

num = 10
data = np.arange(num**2).reshape((num,num))

fig = plt.figure()
ax = fig.add_subplot(111)

cax = ax.imshow(data)

ax.set_xticks(range(num//2))

fig.show()

As a reference, I'm running matplotlib 1.0.0 with python 2.7.0 on a
64-bit Linux (kernel 2.6.31) machine. I can confirm this on python 2.6
and matplotlib 0.99 as well, though.

If this isn't expected behavior, I'll be glad to open a bug report.

Joe,

Thanks for the report. The fix is in svn 8652 and 8653.

Eric

···

On 08/20/2010 12:18 PM, Joe Kington wrote:

Thanks!
-Joe