I'm trying to share two subplots axis, but I need to share x axis after the figure was created. So, for instance, I create this figure:
import numpy as np
import matplotlib.pyplot as plt
t= np.arange(1000)/100.
x = np.sin(2*np.pi*10*t)
y = np.cos(2*np.pi*10*t)
fig=plt.figure()
ax1 = plt.subplot(211)
plt.plot(t,x)
ax2 = plt.subplot(212)
plt.plot(t,y)
# some code to share both x axis
plt.show()
Instead of the comment I would insert some code to share both x axis.
I didn't find any clue how i can do that. There are some attributes
_shared_x_axes and _shared_x_axes when i check to figure axis (fig.get_axes()) but I don't know how to link them.