我正在嘗試繪制一些圖表,我希望它看起來像那樣,并在 python 中進行。
我嘗試了很多東西,但它看起來比我想要實作的要丑陋,任何幫助將不勝感激

uj5u.com熱心網友回復:
您可以使用網格嘗試遵循此模式
from matplotlib.gridspec import GridSpec
fig = plt.figure(constrained_layout=True)
gs = GridSpec(4, 4, figure=fig)
ax1 = fig.add_subplot(gs[:, :2])
# identical to ax1 = plt.subplot(gs.new_subplotspec((0, 0), colspan=3))
ax2 = fig.add_subplot(gs[:2, 2])
ax3 = fig.add_subplot(gs[:2, 3])
ax4 = fig.add_subplot(gs[2:, 2])
ax5 = fig.add_subplot(gs[2:, 3])
plt.show()

uj5u.com熱心網友回復:
您可以使用
uj5u.com熱心網友回復:
也許比上面更容易(使用相對現代的 matplotlib):
fig, axs = plt.subplot_mosaic(
[['A', 'b', 'c'],
['A', 'd', 'e']],
gridspec_kw={'width_ratios':[2, 1, 1]},
constrained_layout=True
)
請注意,當 3.6 發布時,您可以這樣做:
fig, axs = plt.subplot_mosaic(
[['A', 'b', 'c'],
['A', 'd', 'e']],
width_ratios=[2, 1, 1],
constrained_layout=True
)
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/503652.html
標籤:Python matplotlib 子情节
上一篇:軟體工程 統一建模語言(Unified Modeling Language UML) 第4篇隨筆
下一篇:回圈時更改ylim
