From: Scott S. <sco...@gm...> - 2010-11-18 14:58:30
|
Hi, It seems that the autofmt_xdate helper method is broken when twinx is used. Consider the script below: ----------------------------------------- import datetime as dt import numpy as np import matplotlib.pyplot as plt from matplotlib.dates import date2num strt = dt.datetime(2000, 3, 15, 6) delta = dt.timedelta(hours=6) date_list = [(strt + i*delta) for i in range(100)] x = date2num(date_list) y = np.sin(x) z = np.cos(x) fig, ax1 = plt.subplots() ax1.plot(date_list, y, 'b-') ax2 = ax1.twinx() ax2.plot(date_list, z, 'r-') # using the auto format method doesn't work fig.autofmt_xdate() plt.show() ----------------------------------------- This is because the 'is_last_row' attribute isn't present on ax2 and len(fig.axes) != 1 when the autofmt_xdate method is called on fig. The attached patch fixes it for me and still seems to give the advertised behaviour for single and vertically stacked subplots. Cheers, Scott |