The previous answer from tcaswell on how to create shared axis for plots which are not on the same figure was perfect :) But I'm now wondering how to disable the shared axis and reenable them without having to redraw or destroy anything ? (I have multiple graphs and I want to add a button that the user can click to disable/enable those shared axes) I found a way :
import matplotlib.pyplot as plt
fig = plt.figure()
ax1 = fig.add_subplot(111)
fig2 = plt.figure()
ax2 = fig2.add_subplot(111, sharex=ax1)
to create the shared axis and then
fig2.delaxes(ax2)
ax2 = fig2.add_subplot(111)
but this require to redraw everything and can take some times. I didnt find a simple function to disable the link. Is there a lighter way than what I did ?
Thanks !
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…