2017-01-06 11 views
2

私は同じサイズのプロットの3x2グリッドを持っています。サブプロットの中央のタイトル(matplotlib、pyplot)

は、6つのプロットの上に中央のタイトルを持つようにしています。私は、各サブプロットの上に特定のタイトルのためのコマンド

plt.title("Almost awesome title") # (2) 

を使用します。今は難しい部分です:私はサブプロットの1行目と2行目の間に中心のタイトルが必要です。 (2)の位置パラメータを(1.1,1.0)のようなものに操作した後、私は正しく/きれいにフォーマットされた図形を得ることができません。

TL; DR:私は下の写真の上に示すように置かれる追加のplt.suptitle("Title")をしたい:(フォトショップ)

Arbitrary plot to illustrate point of centered titles inside subplots

答えて

2

だけの行の間にいくつかの余分な部屋を作り、テキストを追加します。

fig, axs = plt.subplots(2, 2) 
plt.sca(axs[0,0]) 
plt.title('Sigmoid') 
plt.sca(axs[0,1]) 
plt.title('ReLU') 
plt.suptitle('Activation functions') 

# Adjust vertical_spacing = 0.5 * axes_height 
plt.subplots_adjust(hspace=0.5) 

# Add text in figure coordinates 
plt.figtext(0.5, 0.5, 'Effect of bias addition', ha='center', va='center') 

enter image description here

+0

ああ、図の座標は私には新しく、それはそれを解決しました!すばらしいです! –

関連する問題