我有一个奇怪的问题,我有两个几乎完全相同的图表函数,但是文本只出现在其中一个上。
我的第一个功能(显示文字)是:
x = day
labels = day
for account in accounts:
plt.plot(x, eval(account), label=account)
plt.xticks(x, labels, rotation='45')
plt.xlabel('Date', fontsize=16)
plt.ylabel('Followers', fontsize=16)
plt.legend(loc='center', bbox_to_anchor=(0.87, 0.5), fancybox=True, shadow=True, ncol=1)
plt.grid(alpha=0.3)
plt.tight_layout()
t = ("This is a really long string that I'd rather have wrapped so that it "
"doesn't go outside of the figure, but if it's long enough it will go "
"off the top or bottom!")
plt.text(4, 1, t, ha='left', rotation=15, wrap=True)
plt.text(6, 5, t, ha='left', rotation=15, wrap=True)
plt.text(5, 5, t, ha='right', rotation=-15, wrap=True)
plt.text(5, 10, t, fontsize=18, style='oblique', ha='center',
va='top', wrap=True)
plt.text(3, 4, t, family='serif', style='italic', ha='right', wrap=True)
plt.text(-1, 0, t, ha='left', rotation=-15, wrap=True)
plt.draw()
plt.show()
并生成图表: chart that shows text
我的第二个功能不显示文本,我也不知道为什么:
print_accounts_table()
account = input(str('Enter a username from the list (cAsE sEnSiTivE): @'))
x = day
labels = day
plt.plot(x, eval(account), label=account)
plt.xticks(x, labels, rotation='45')
plt.xlabel('Date', fontsize=16)
plt.ylabel('Followers', fontsize=16)
plt.legend(loc='center', bbox_to_anchor=(0.87, 0.5), fancybox=True, shadow=True, ncol=1)
plt.grid(alpha=0.3)
plt.tight_layout()
t = ("This is a really long string that I'd rather have wrapped so that it "
"doesn't go outside of the figure, but if it's long enough it will go "
"off the top or bottom!")
plt.text(4, 1, t, ha='left', rotation=15, wrap=True)
plt.text(6, 5, t, ha='left', rotation=15, wrap=True)
plt.text(5, 5, t, ha='right', rotation=-15, wrap=True)
plt.text(5, 10, t, fontsize=18, style='oblique', ha='center',
va='top', wrap=True)
plt.text(3, 4, t, family='serif', style='italic', ha='right', wrap=True)
plt.text(-1, 0, t, ha='left', rotation=-15, wrap=True)
plt.draw()
plt.show()
生成图表:chart without text
有人知道这是为什么吗?谢谢