The way axis sharing is implemented, everything is shared; a
> single axis object is used for more than one axes object. I
> agree that this is not always what one wants, but I think it
> would be quite difficult to change, so for now you will need
> to forgo the sharey kwarg and instead manually synchronize
> the properties that you want the axes to have in common.
> Unless John has a better idea, of course...
This time I do
The axis doesn't share everything -- it shares a locator and the view
limits. When you do ylim([]) you are telling the y tick locator to
use no ticks, and this is shared. There is a workaround -- no
terribly elegant but servicable, and one I use all the time.
Suppose ax1 and ax2 share the xaxis and you only want tick labels on
ax2
ax1 = fig.add_subplot(211)
ax2 = fig.add_subplot(212, sharex=ax1)
ax1.plot(something)
ax2.plot(somethingelse)
for label in ax1.get_xticklabels():
label.set_visible(False)
The key idea is that the actual ticks are not shared (they can't be
because their y locations are different). But their x locations are
shared (which is why ax1.set_xlim([]) doesn't do what you want. But
you can set the visibility property to make them invisible, which
works.
Should be a recipe in the cookbook, enterprising mailing list readers.
JDH