From: John H. <jd...@gm...> - 2007-02-13 15:30:23
|
On 2/13/07, Eric Emsellem <ems...@ob...> wrote: > Hi, > > I would need the equivalent of twinx, but for other axis, so a "twiny" > function. Shouldn't it be in mpl already? > > thanks for your help, > At the time noone wanted it, but it's easy enough to do. I just added the following to pylab svn: def twiny(ax=None): """ Make a second axes overlay ax (or the current axes if ax is None) sharing the yaxis. The ticks for ax2 will be placed on the top, and the ax2 instance is returned. """ if ax is None: ax=gca() ax2 = gcf().add_axes(ax.get_position(), sharey=ax, frameon=False) ax2.xaxis.tick_top() ax2.xaxis.set_label_position('top') ax.xaxis.tick_bottom() draw_if_interactive() return ax2 |