# --*-- coding: utf-8 --*--
from matplotlib.font_manager import FontProperties
import matplotlib.pyplot as plt

font = FontProperties(fname=r"/usr/share/fonts/win/msyh.ttf", size=14)
fig = plt.figure(figsize=(6, 6))

x = [1, 2, 3, 4, 5, 6, 7, 8]
y = []
for i in x:
    y.append(-(i * i) + i + 3)


ax = fig.add_subplot(111)
ax.plot(x, y, label=u'我我问')

plt.title(u'测试程序', fontproperties=font)
plt.xlabel(u'x轴', fontproperties=font)
plt.ylabel(u'y轴', fontproperties=font)


plt.grid(True)
plt.legend(prop=font)  # 要让lable也支持中文
plt.show()

http://hi.baidu.com/bithigher/item/b9ce6d85dc102adc98255fb7 感谢这篇文章

相关文章:

  • 2021-11-10
  • 2021-12-06
  • 2022-02-10
  • 2021-06-23
  • 2022-01-16
  • 2022-12-23
猜你喜欢
  • 2021-07-26
  • 2021-06-28
  • 2021-04-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-02
相关资源
相似解决方案