python matplotlib模块文字图
程序员文章站
2024-01-15 19:14:34
...
import matplotlib.pylab as plt
import numpy as np
#处理中文乱码
plt.rcParams['font.sans-serif'] = ['Microsoft YaHei']
#写入文本
#plt.text
plt.figure(figsize=(8,4))
plt.text(0.6,0.7,'天王盖地虎',size= 20,
rotation=45,
ha='center',va='center',
bbox=dict(boxstyle='round',
ec=(1.,0.6,0.5),
fc=(1.,0.8,0.8)
))
plt.text(0.55,0.06,'宝塔镇河妖',size= 20,
rotation=-25,
ha='right',va='top',
bbox=dict(boxstyle='square',
ec=(1.,0.5,0.5),
fc=(1.,0.8,0.8)
))
plt.show()