There is a nice little trick where you can make two axes share the
same xaxis. Then when you pan or zoom on one, the other is
automagically changed to
ax1 = subplot(211)
ax2 = subplot(212, sharex=ax1)
But that's not retroactive, or is it ? i.e. if ax2 has a wider x range than ax1, it won't show up.
f = figure(1)
s1 = subplot(211)
s1.plot([1,2,3], [1,2,3])
s2 = subplot(212, sharex = s1)
s2.plot([4,5,6], [1,2,3])
I came up with the following function to solve that problem. Is there a more elegant solution?
def uniform_limits(axes, xrange = 'widest', yrange = 'widest'):
"""For all axes, sets xlim and ylim to the widest (shortest) range."""
x = []
y = []
for ax in axes:
x.append(ax.get_xlim())
y.append(ax.get_ylim())
x = vstack(asarray(x))
y = vstack(asarray(y))
if xrange == 'widest':
xlims = x.min(0)[0], x.max(0)[1]
elif xrange == 'shortest':
xlims = x.max(0)[0], x.min(0)[1]
if yrange == 'widest':
ylims = y.min(0)[0], y.max(0)[1]
elif yrange == 'shortest':
ylims = y.max(0)[0], y.min(0)[1]
setp(axes, 'xlim', xlims, 'ylim', ylims)
David
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users