1. Python的figure參數主要有:
def figure(num=None, # autoincrement if None, else integer from 1-N figsize=None, # defaults to rc figure.figsize dpi=None, # defaults to rc figure.dpi facecolor=None, # defaults to rc figure.facecolor edgecolor=None, # defaults to rc figure.edgecolor frameon=True, FigureClass=Figure, clear=False, **kwargs ):
可以設置圖片大小、分辨率、顏色等。
2. subplot子圖繪制,子圖的繪圖參數可以分別設置
plt.figure(1) x1 = np.linspace(-0.2, 2, 10) y1 = x1**2 + 0.3 plt.subplot(121) plt.scatter(x1, y1) plt.xlabel('X') plt.ylabel('Y') plt.title('test_1') x2 = np.linspace(-0.2, 2, 10) y2 = x2 + 0.3 plt.subplot(122) plt.plot(x2, y2, color="red", linewidth=1.0, marker = 's', linestyle="--") ## plt.plot(x, y, color="#ef5492", linewidth=2.0, marker = 's', linestyle="--") # plt.plot(x2, y2, 'rs--') plt.xlabel('X') plt.ylabel('Y') plt.title('test_2') plt.show()
3. 在同一張圖片上顯示多種圖形,簡單說把 plt.show()放在最后即可
import matplotlib.pyplot as plt import numpy as np plt.figure(2) x1 = np.linspace(-0.2, 2, 10) y1 = x1**2 + 0.3 plt.scatter(x1, y1) x2 = np.linspace(-0.2, 2, 10) y2 = x2 + 0.3 plt.plot(x2, y2, color="red", linewidth=1.0, marker = 's', linestyle="--") ## plt.plot(x, y, color="#ef5492", linewidth=2.0, marker = 's', linestyle="--") # plt.plot(x2, y2, 'rs--') plt.xlabel('X') plt.ylabel('Y') plt.title('test_3') plt.show()
更多參數設置可見:
https://www.cnblogs.com/qi-yuan-008/p/12588351.html
https://www.cnblogs.com/qi-yuan-008/p/12588121.html
##
參考: