[英]how to set matplotlib figsize using axes and subplots
您好,我有一個帶有 matplotlib 的非常基本的圖,但我希望能夠設置圖形大小,但我對在不使用多個子圖時如何執行此操作感到困惑。 我對 figsize 和 subplots 之間的關系感到困惑,請參閱下面的代碼:
plt.figure(figsize=(10,10))
y = np.arange(1,6,1)
y1 = y**2
y2 = y**3
y3 = y**4
x = np.arange(1,101,20)
fig, ax = plt.subplots()
ax.plot(x,y1)
ax.plot(x,y2)
ax.plot(x,y3)
只需放入 1 行 1 列子圖,就可以得到一個圖。
fig, ax = plt.subplots(1, 1, figsize=(8,8))
y = np.arange(1,6,1)
y1 = y**2
y2 = y**3
y3 = y**4
x = np.arange(1,101,20)
fig, ax = plt.subplots()
ax.plot(x,y1)
ax.plot(x,y2)
ax.plot(x,y3)
fig.savefig('eightbyeight.png', dpi = 300)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.