0
我不明白为什么我的文字标题没有出现在我的情节。我发现这个文档对于图例和标题标签的放置顺序非常混乱..文本标题没有出现matplotlib
我的代码在这里,我不知道什么是错的。一切都如我所料(标题,轴标签,日期格式,...)出现,除了标题的文本不在那里。
fig = plt.figure(figsize=(24, 12), dpi=60)
ax = fig.add_subplot(111)
plt.plot(datetime_series,ws_cumsum_mean1,label='1979-1994')
plt.plot(datetime_series,ws_cumsum_mean2,label='1996-2005')
plt.plot(datetime_series,ws_cumsum_mean3,label='2006-2014')
txt = '''Caption text'''
plt.legend(loc='best')
这是我尝试添加标题:
ax.text(0.5,-0.5,txt,transform=ax.transAxes)
。
plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%d-%m'))
plt.ylabel('Y label title')
plt.xlabel('X label title')
plt.title('Plot title')
丹麦人,但是,我把(0.5,-0.5)这样它应该我的文字不会出现在图中,并且它会出现在下面..我只是想要一个数字标题下面的数字。但是,用我在问题中列出的当前代码,根本没有文字出现。 – pwprnt
图下方意思是在图外。外面的一切都是不可见的。将它与浏览器窗口进行比较;如果您将浏览器窗口放置在屏幕下方(假设y = -500像素),则无法再看到它。 – ImportanceOfBeingErnest
好的,谢谢,这是有道理的。那么我如何添加标题? – pwprnt