出于某種原因,我在一對餅圖和它們的標題之間獲得了很大的空間。我不確定是什么控制了這個間距。我想折疊這個空間。至少,我們可以將餡餅放在空間內嗎?這是一些類似于我實際做的示例代碼:import matplotlib.pyplot as pltx = ['a', 'b', 'c']y = [1.1, 3.5, 2.2]y1_sizes = yy2_sizes = yfig, axarr = plt.subplots(1, 2)ax1 = axarr[0]ax2 = axarr[1]ax1.pie(y1_sizes, shadow=True, startangle=90, autopct='%1.1f%%')ax1.axis('equal')ax1.set_title('Old Stuff')ax2.pie(y2_sizes, shadow=True, startangle=90, autopct='%1.1f%%')ax2.axis('equal') ax2.set_title('New Stuff')lgd1 = ax1.legend(x, loc='lower center')lgd2 = ax2.legend(x, loc='lower center')fig.suptitle('My Chart Title', fontweight='bold')這是結果
1 回答

尚方寶劍之說
TA貢獻1788條經驗 獲得超4個贊
我在評論中回答你的問題:“有沒有辦法向下移動軸標題?”。您可以通過使用參數在分數坐標中指定各個標題的垂直位置來實現這一點y。
ax1.set_title('Old Stuff', y=0.8)
ax2.set_title('New Stuff', y=0.8)
fig.suptitle('My Chart Title', fontweight='bold', y=0.85)
添加回答
舉報
0/150
提交
取消