Python:Matplotlib:如何在其中打印一个具有不同大小的文本? [英] Python: Matplotlib: how to print ONE text with different sizes in it?
本文介绍了Python:Matplotlib:如何在其中打印一个具有不同大小的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在matplotlib中是否可以在一个字符串中包含一个具有不同字体大小的文本框?
is it possible in matplotlib to have a textbox with different font sizes within one string?
感谢帮助
推荐答案
我认为如果不使用LaTeX文本渲染器就无法做到这一点.要使用此功能,
I don't think this can be done without using the LaTeX text renderer. To use this do,
from matplotlib import rcParams
rcParams['text.usetex'] = True
然后,您可以使用标准的LaTeX语法打印多字体大小的字符串,例如
Then you can print multi-fontsize strings using standard LaTeX syntax, e.g.
from matplotlib import pyplot as plt
ax = plt.axes()
ax.text(0.5, 0.5, r'{\tiny tiny text} normal text {\Huge HUGE TEXT}')
有时候LaTeX字体渲染器并不理想(例如,请注意,刻度标签字体与普通的MPL刻度标签不同),但是它肯定更灵活.
Sometimes the LaTeX font renderer isn't ideal (e.g. note that tick-label fonts are different than normal MPL tick labels), but it is certainly more flexible.
这篇关于Python:Matplotlib:如何在其中打印一个具有不同大小的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文