我目前在
python中使用matplotlib來繪制一些數據,但是我希望圖表的標題位于Y軸上,因為沒有足夠的空間來存儲一個圖形的標題和另一個圖形的x軸標簽.我知道我可以將hspace設置為更大的數字但是,我不想這樣做,因為我計劃將幾個圖表堆疊在一起,如果我調整hspace,那么圖表將是真的簡短而難讀.
like this http://oi39.tinypic.com/2a4r5i1.jpg
這是我的代碼
#EXAMPLE CODE
import numpy as np
import matplotlib.pyplot as plt
fig=plt.figure()
rect = fig.patch
rect.set_facecolor('#31312e')
x = [1,2,3,4,5,6,7,8]
y = [4,3,8,2,8,0,3,2]
z = [2,3,0,8,2,8,3,4]
ax1 = fig.add_subplot(2,1,1, axisbg='gray')
ax1.plot(x, y, 'c', linewidth=3.3)
ax1.set_title('title', color='c')
ax1.set_xlabel('xlabel')
ax1.set_ylabel('ylabel')
ax2 = fig.add_subplot(2,1,2, axisbg='gray')
ax2.plot(x, z, 'c', linewidth=3.3)
ax2.set_xlabel('xlabel')
ax2.set_ylabel('ylabel')
plt.show()
提前致謝