get_xticks() returning wrong ticks after autoscale(tight=True)

Hi

I’ve been trying to do a twiny() plot in matplotlib, but I’ve run into a problem with the ticks when using autoscale with the tight option.

My second xaxis is a function of the first.
An example would be:

···

import numpy as np
import matplotlib.pyplot as plt

Radius = np.arange(32)
Theta = np.sin(np.arange(32))

fig1 = plt.figure()
ax1 = fig1.add_subplot(111)

ax1.plot(Radius, Theta, linestyle=’-’, marker=’.’, c=‘b’, markersize=5)

print(ax1.get_xticks())
plt.show()

fig1 = plt.figure()

ax1 = fig1.add_subplot(111)

ax1.plot(Radius, Theta, linestyle=’-’, marker=’.’, c=‘b’, markersize=5)

ax1.autoscale(tight=True)

print(‘This should be different’)
print(ax1.get_xticks()) # Should not be the same as the last print

plt.show()

This would be a problem if I now were to do:

ax2 = ax1.twiny()

ax2.set_xticks(ax1.get_xticks())

ax2.set_xticklabels(someFunction(ax1.get_xticks()))

Is this a problem with the tight=True option?

Do I have to manually set all the limits?

Cheers

Paul