2016-01-22 181 views

回答

1

激活乳胶文本渲染

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

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

这篇文章应该回答你操纵标题的问题。您可以使用乳胶文本渲染并为该字符串的特定部分调用textbf。

Styling part of label in legend in matplotlib

下面是文档: http://matplotlib.org/users/usetex.html http://matplotlib.org/api/axes_api.html#matplotlib.axes.Axes.set_title

+0

外部链接可以改变的,因此最好是复制一个外部页面的兴趣区间在您的评论。复制外部页面的有趣部分并引用它的来源是最好的! –

6

从matplotlib版本2, 没有必要使用乳胶(这将需要工作胶乳安装)。人们可以使用普通的MathText以粗体显示标题的一部分。

import matplotlib.pyplot as plt 
number = 2017 
plt.title("This is title number: " + r"$\bf{" + str(number) + "}$") 
plt.show() 

enter image description here