原文鏈接 https://www.zhihu.com/question/51745620
# figure 畫板
# axes 軸域,包括軸的集合和一些其他特征,畫紙
# subplot() vs. add_axes()
import numpy as np import matplotlib.pyplot as plt fig = plt.figure() ax3 = fig.add_axes([0.1,0.1,0.8,0.8]) ax4 = fig.add_axes([0.71,0.71,0.4,0.4]) plt.show()
# axes方法和pyplot函數
兩種方法都可以實現一樣的結果,這也代表是貫穿python變成的兩種思路:函數式編程和對象式編程,我們這里可以比較一下兩套工具的優缺點:
axis顧名思義就是軸。
axes簡單說來就是靈活的子圖。和Subplot的關系見官網上axes的說明:
Most of you are probably familiar with the Subplot, which is just a special case of an Axes that lives on a regular rows by columns grid of Subplot instances. If you want to create an Axes at an arbitrary location, simply use the add_axes() method which takes a list of [left, bottom, width, height] values in 0-1 relative figure coordinates: