import numpy as np import pandas as pd from matplotlib import pyplot as plt if __name__ == "__main__": #第一組數據 x1 = list(range(5)) y1 = list(map(lambda x:x**2,x1)) #第二組數據 x2 = list(range(5,11)) y2 = list(map(lambda x:x**2/2,x2)) #做第一幅圖 2*1矩陣 ax1 = plt.subplot(121) #傳入數據7 ax1.plot(x1,y1) #為第一張圖片設置標題 plt.title('d1') ax2 = plt.subplot(122) #傳入數據 ax2.plot(x1,y1) #為第二張圖片設置標題 plt.title('d2') #刪除子圖 plt.delaxes(ax2) plt.subplot(ax2) #繪制 plt.show()
