| 
 | 
 
 本帖最后由 matlab的旋律 于 2021-1-5 12:42 编辑  
 
第一种方法:- from matplotlib import pyplot as plt 
 
 - import numpy as np
 
  
- fig, ax = plt.subplots(figsize=(12,8),ncols=2,nrows=1,sharex=True, sharey=False)#此时x同时放缩,y轴不同时放缩
 
 - ax[0].plot(np.sin(np.arange(0, 3, 0.1)),'-r')
 
 - ax[1].plot(np.cos(np.arange(0, 3, 0.1)),'--k')
 
 - plt.show()
 
  复制代码 第二种方法:- from matplotlib import pyplot as plt 
 
 - import numpy as np
 
  
- ax1 = plt.subplot(1,2,1)
 
 - ax1.plot(np.sin(np.arange(0, 3, 0.1)))
 
 - ax2 = plt.subplot(1,2,2, sharex=ax1,sharey=ax1)
 
 - ax2.plot(np.sin(np.arange(0, 3, 0.1)))
 
 - plt.show()
 
  复制代码 
 
 
 |   
 
 
 
 |