python 给文本加下划线_python-matplotlib图例中的下划线文本

我的图例中需要带下划线.我发现一个问题回答here

但我完全不了解LaTeX.我需要在图例中强调“由伽马光谱确定的含量”(代码的第53行).我尝试从链接中执行以下操作:

r'\underline{Content determined from gamma spectroscopy} ',

但确切的文字只会显示在图例中.我该如何在文字上加上下划线?

import matplotlib.pyplot as plt

from matplotlib.patches import Rectangle

eu_cl = 0.1

co_cl = 2.0

ca_eu_gs = 0.05 / eu_cl

ca_co_gs = 0.46 / co_cl

fa_eu_gs = 0.11 / eu_cl

fa_co_gs = 0.76 / co_cl

ce_eu_gs = 0.03 / eu_cl

ce_co_gs = 0.26 / co_cl

ca_eu_ms = 0.04 / eu_cl

ca_co_ms = 1.05 / co_cl

fa_eu_ms = 0.01 / eu_cl

fa_co_ms = 1.85 / co_cl

ce_eu_ms = 0.08 / eu_cl

ce_co_ms = 1.44 / co_cl

y_co = [1,1,1,1,1,1,1e-1,1e-2,1e-3,0]

x_co = [0,1e-4,1e-3,1e-2,1e-1,1e0,1e0,1e0,1e0,1e0]

#y_eu = [0, 1e-3, 1e-2, 1e-1, 1e0]

#x_eu = [1,1,1,1,1]

plt.rcParams['legend.loc'] = 'best'

plt.figure(1)

plt.ylim(1e-3, 1e4)

plt.xlim(1e-4, 1e3)

#plt.autoscale(enable=True, axis='y', tight=None)

#plt.autoscale(enable=True, axis='x', tight=None)

ca_gs = plt.scatter(ca_eu_gs, ca_co_gs, color='b', marker='o')

fa_gs = plt.scatter(fa_eu_gs, fa_co_gs, color='r', marker='o')

ce_gs = plt.scatter(ce_eu_gs, ce_co_gs, color='m', marker='o')

ca_ms = plt.scatter(ca_eu_ms, ca_co_ms, color='b', marker='^')

fa_ms = plt.scatter(fa_eu_ms, fa_co_ms, color='r', marker='^')

ce_ms = plt.scatter(ce_eu_ms, ce_co_ms, color='m', marker='^')

extra = Rectangle((0, 0), 1, 1, fc="w", fill=False, edgecolor='none', linewidth=0)

extra1 = Rectangle((0, 0), 1, 1, fc="w", fill=False, edgecolor='none', linewidth=0)

clearance, = plt.plot(x_co, y_co, color='g')

#plt.plot(x_eu, y_eu, color='g')

plt.loglog()

plt.xlabel('Europium (ppm)')

plt.ylabel('Cobalt (ppm)')

plt.legend([extra, ca_gs, fa_gs, ce_gs, extra1, ca_ms, fa_ms, ce_ms , clearance], ("Content determined from gamma spectroscopy" ,

"Coarse aggregate","Fine aggregate","Cement","Content determined from ICP-MS","Coarse aggregate","Fine aggregate","Cement","D/C = 1")

, scatterpoints = 1)

print('plots created')

plt.show()

编辑:

我添加了注释中提到的以下内容以打开LaTeX

rc('text', usetex=True)

但这会导致一整串错误,并以以下错误结尾:

RuntimeError: LaTeX was not able to process the following string:

'$10^{-4}$'

Here is the full report generated by LaTeX:

我猜这是因为我现在必须使用LaTeX格式化所有文本.有没有办法只使用LaTex格式化其中的一部分.我只是没有经验,现在真的不是学习它的最佳时间(不过有一天我会).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值