【问题标题】:How to change font color offsetbox TextArea如何更改字体颜色偏移框TextArea
【发布时间】:2018-08-19 20:51:12
【问题描述】:
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)

有没有办法改变这个文本的颜色? 谢谢!

【问题讨论】:

    标签: python matplotlib text colors


    【解决方案1】:

    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()
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-05-18
    • 2011-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多