from matplotlib.offsetbox import TextArea
rc('font',**{'family': 'Courier New, monospace', 'size' : 26})
fig, ax = plt.subplots()
txt = TextArea("Hello World!")
text = AnnotationBbox(txt, (0, 0, 0))
ax.add_artist(text)
有什么办法可以改变这个文本的颜色吗? 谢谢!
最佳答案
Textarea
有一个参数 textprops
可用于设置文本的颜色。
import matplotlib.pyplot as plt
from matplotlib.offsetbox import TextArea, AnnotationBbox
fig, ax = plt.subplots()
txt = TextArea("Hello World!", textprops=dict(color="crimson"))
text = AnnotationBbox(txt, (0.5, 0.5))
ax.add_artist(text)
plt.show()
关于python - 如何更改offsetbox TextArea的字体颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49224993/