问题
is it possible in matplotlib to have a textbox with different font sizes within one string?
Thanks for help
回答1:
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
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}')
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.
来源:https://stackoverflow.com/questions/26767186/python-matplotlib-how-to-print-one-text-with-different-sizes-in-it