我想在图中的轴上添加文字,如上图所示。
我已经计算出下图,但无法在轴上添加文字" 20℃"谢谢。
下面是我的代码:
theltaa=array([20,800,1200])
thermalconductivity=array([53.3,27.3,27.3])
fig = figure(figsize=(8,4))
ax = fig.add_axes([0.1, 0.2, 0.8, 0.7])
ylim(20,60)
fig.patch.set_alpha(0.0)
ax.patch.set_alpha(0.0)
ax.xaxis.set_major_locator(MultipleLocator(200))
#ax.xaxis.set_major_formatter(FormatStrFormatter('%d'))
ax.xaxis.set_minor_locator(MultipleLocator(100))
ax.yaxis.set_major_locator(MultipleLocator(20))
#ax.yaxis.set_major_formatter(FormatStrFormatter('%d'))
ax.yaxis.set_minor_locator(MultipleLocator(10))
ax.axvline(20, linestyle='--', color='k')
text(25,0,"$20^{\circ}C$', fontsize=12)### this does not work
ax.xaxis.grid(True,'minor')
ax.yaxis.grid(True,'minor')
ax.xaxis.grid(True,'major',linewidth=2)
ax.yaxis.grid(True,'major',linewidth=2)
plot(theltaa,thermalconductivity,'H-')
xlabel(r"$\theta_a(^{\circ}C)$",fontsize=18)
ylabel(r"$\lambda_a(W/mK)$",fontsize=18)
show()
fig.savefig('tc.png', transparent=True)
我尝试添加
text(25,0,"$20^{\circ}C$', fontsize=12)### this does not work
不知何故,这不起作用......