Matplotlib/Pyplot: How to zoom subplots together?

后端 未结 3 527
离开以前
离开以前 2020-12-07 18:21

I have plots of 3-axis accelerometer time-series data (t,x,y,z) in separate subplots I\'d like to zoom together. That is, when I use the \"Zoom to Rectangle\" tool on one p

3条回答
  •  春和景丽
    2020-12-07 19:05

    The easiest way to do this is by using the sharex and/or sharey keywords when creating the axes:

    from matplotlib import pyplot as plt
    
    ax1 = plt.subplot(2,1,1)
    ax1.plot(...)
    ax2 = plt.subplot(2,1,2, sharex=ax1)
    ax2.plot(...)
    

提交回复
热议问题