Bug in twiny()

Hi,

there is a minor bug in the axes.twiny() function. Apparently the parent axes xlim() values are not copied.
Example:

from numpy import *
import matplotlib.pyplot as plt

x=linspace(-2.0, 2.0, 100)
y=x**2

fig=plt.figure()
ax1=fig.add_subplot(111)
ax1.plot(x, y)

ax2=ax1.twiny()
ax1.get_xlim() --> (-2.0, 2.0)
ax2.get_xlim() --> (0.0, 1.0)

It is simple to fix by hand, but I do not think that this is the desired behavior.

Thanks,

Benjamin

I can see the argument for copying the x limits, but let's dig further
here. Should we also copy the autoscalex switch? The x-axis
ticks/tickers/tick formatters? Right now, the way it works, the x-axis in
the new axes object is set up just like any other axes, with only the
y-axis properties tied together. I personally prefer simplicity and
consistency over "magic". Every time I make an axes, it is set up the same
way.

We are about ready to re-examine our limit handling code soon, so this is a
good question to ask in that light. One of the things we are looking to do
is to have a concept of "null limits" (in other words, limits that have yet
to be explicitly set). It may make sense at that point to consider such
behaviors as what you suggest.

Cheers!
Ben Root

ยทยทยท

On Tue, Jun 4, 2013 at 3:58 AM, trendelkamp <trendelkamp@...4370...>wrote:

Hi,

there is a minor bug in the axes.twiny() function. Apparently the
parent axes xlim() values are not copied.
Example:

from numpy import *
import matplotlib.pyplot as plt

x=linspace(-2.0, 2.0, 100)
y=x**2

fig=plt.figure()
ax1=fig.add_subplot(111)
ax1.plot(x, y)

ax2=ax1.twiny()
ax1.get_xlim() --> (-2.0, 2.0)
ax2.get_xlim() --> (0.0, 1.0)

It is simple to fix by hand, but I do not think that this is the desired
behavior.