Jda*_*eer 2 python plot matplotlib
在从tcaswell以前的答案如何为地块不属于同一人物创建共享轴是完美的:)但现在我不知道如何禁用共享轴和重新启用它们,而不必重新绘制或破坏任何东西?(我有多个图形,我想添加一个按钮,用户可以单击该按钮以禁用/启用这些共享轴)我找到了一种方法:
import matplotlib.pyplot as plt
fig = plt.figure()
ax1 = fig.add_subplot(111)
fig2 = plt.figure()
ax2 = fig2.add_subplot(111, sharex=ax1)
Run Code Online (Sandbox Code Playgroud)
创建共享轴,然后
fig2.delaxes(ax2)
ax2 = fig2.add_subplot(111)
Run Code Online (Sandbox Code Playgroud)
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 !
EEE*_*EEE 11
你可以做:
ax2.get_shared_x_axes().remove(ax1)
Run Code Online (Sandbox Code Playgroud)
参考: