gpt4 book ai didi

python - matplotlib、python图例中如何显示℃?

转载 作者:行者123 更新时间:2023-11-28 22:48:07 31 4
gpt4 key购买 nike

下面是一些代码,但我真的不知道如何让℃显示它应该的样子。我认为 matplotlib 足以胜任这种工作。有高手能帮我走出这个困境吗?

if i==12:
plot(strain,stress,'1-',label="$1200℃$")

xlabel(r"strain/$\epsilon$",fontsize=18)
ylabel("stress/MPa",fontsize=18)

legend(bbox_to_anchor=(1.01, 1.0,0.8,0.0), loc=2, borderaxespad=0.0)

show()

最佳答案

此解决方案与副本中讨论的字体/unicode 问题完全不同,但您可以使用 Latex 样式的命令来实现此目的:

plt.plot(1, 3, '1-', label=u"$1200^{\circ}C$")
plt.legend()
plt.show()

关于python - matplotlib、python图例中如何显示℃?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25438735/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com