On Thu, Nov 18, 2010 at 8:58 AM, Scott Sinclair <scott.sinclair...@gmail.com
> wrote:
> 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
>
>
I am not very familiar with this part of mpl, but your diff seems to cut out
a few things. In particular, the original code checks to see if the figure
has a single axes object or more. However, your code seems to cut this
check out. Now, it may have been that the check could have been
unnecessary, but I am not sure. I am curious as to your insight on this.
In addition, the original code called "self.subplots_adjust(bottom=bottom)"
only when all subplots were on the last row. Now, it seems that it is
always called no matter what.
Ben Root
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel