簡體   English   中英

子圖中的 wspace 和 hspace,軸的寬度 - python3

[英]wspace and hspace in subplots, width of axes - python3

如何在子圖中制作 wspace 和 hspace? 我有一個類型的代碼:

plt.figure(figsize=(12, 10))

fig1=plt.subplot(231)
plt.plot(x, y)

fig2=plt.subplot(232)
plt.plot(x, y)

fig3=plt.subplot(233)
plt.plot(x, y)

fig4=plt.subplot(234)
plt.plot(x, y)

fig5=plt.subplot(235)
plt.plot(x, y)

fig6=plt.subplot(236)
plt.plot(x, y)

我試圖為個人數字擴大 wspace:

plt.figure(figsize=(12, 10))

fig1=plt.subplot(231)
fig1.subplots_adjust(wspace=2)

錯誤:

    fig1.subplots_adjust(wspace=2)
AttributeError: 'AxesSubplot' object has no attribute 'subplots_adjust'

以及如何更改所有軸的寬度?

我試過:

import matplotlib as mpl

mpl.rcParams['lines.linewidth'] = 2

您會收到錯誤消息,因為 subplot 返回一個 Axes 對象,而 subplots_adjust 是一個 Figure 方法。 如果要同時返回 Figure 和 Axes 對象,則需要調用 subplots。 否則,您可以簡單地調用 plt.subplots_adjust()。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM