我目前在
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()
提前致谢