Hello all,

I noticed some unusual behavior with specific combinations of axes.twinx and pyplot.xticks. It seems that under certain conditions, the pyplot.xticks command can cause an x offset of the plots. Here’s a relatively short example (as written, this works fine):

import numpy as np

import matplotlib.pyplot as plt

x = np.linspace(-np.pi, np.pi, 1000)

fig = plt.figure()

ax1 = plt.axes()

ax1.plot(x, np.sin(x)+1)

plt.ylim(-1,2)

ax2 = ax1.twinx()

ax2.plot(x, np.sin(x) )

plt.ylim(-1,2)

plt.xlim(-np.pi, np.pi)

ts = np.linspace(-1, 3, 5)

#ts = np.linspace(-1, 4, 5)

plt.xticks( ts, [’%.2f’%i for i in ts] )

plt.show()

However, if the comment on the ‘ts’ array creation code is reversed, the second plot appears offset from the original.

I realize it is idiotic to put ticks outside the axis range, but this caused some problems when I inadvertently did it once (or more…).

I’ve tried this with Matplotlib 1.0.1/Python 2.6.6 (Python x,y) on Windows 7 and Matplotlib 1.0.1/Python 2.7.1 on Gentoo Linux.

Thanks

Ryan