I'm trying to share matplotlib axes after (example axsA) they've been plotted (not just after they've been created). Contrary to my expectation, after doing the join, the axes do not get redrawn with shared xlims, even if I do plt.draw() and plt.show():
import matplotlib.pyplot as plt
# Share two subplot axes AFTER plotting
figA, axsA = plt.subplots(1, 2, sharex=False)
axsA[0].plot(range(0, 10), range(10))
axsA[1].plot(range(3, 13), range(10))
axsA[0].get_shared_x_axes().join(axsA[0], axsA[1])
figA.suptitle('Join after plotting: x-axes limits are not the same in the two axes.')
plt.draw()
plt.show()
I seem able to achieve shared axes only if I join them in a Grouper object before plotting:
# Share two subplot axes BEFORE plotting
figB, axsB = plt.subplots(1, 2, sharex=False)
axsB[0].get_shared_x_axes().join(axsB[0], axsB[1])
axsB[0].plot(range(0, 10), range(10))
axsB[1].plot(range(3, 13), range(10))
figB.suptitle('Join after creation, before plotting: x-axes limits are the same oin both axes.')
Is this a bug in matplotlib.pyplot or in my understanding?