将matplotlib标题的一部分加粗并使用不同的颜色 [英] Make part of a matplotlib title bold and a different color

查看:1586
本文介绍了将matplotlib标题的一部分加粗并使用不同的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将标题的一部分更改为粗体.例如:

I would like to change part of a title to be bold. For example:

plt.title("This is title number: " + str(number))

给出上面的标题,我该如何加粗str(number)部分.

Given a title like the above, how would I bold the str(number) part.

推荐答案

激活乳胶文本呈现

from matplotlib import rc
rc('text', usetex=True)

plt.title("This is title number: " + r"\textbf{" + str(number) + "}")

这篇关于将matplotlib标题的一部分加粗并使用不同的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆