1.matplotlib的编写画图

代码实现为:

matplotlib的编写画图中文forMac

import numpy as np
from scipy import linalg
import matplotlib.pyplot as plt


from matplotlib.font_manager import FontProperties
font_set = FontProperties(fname='/Library/Fonts/Songti.ttc', size=15)

c1,c2= 5.0,2.0
i=np.r_[1:11]
xi=0.1*i
yi=c1*np.exp(-xi)+c2*xi
zi=yi+0.05*np.max(yi)*np.random.randn(len(yi))
A=np.c_[np.exp(-xi)[:,np.newaxis],xi[:,np.newaxis]]
c,resid,rank,sigma = linalg.lstsq(A,zi)
xi2= np.r_[0.1:1.0:100j]
yi2=c[0]*np.exp(-xi2)+ c[1]*xi2
plt.xlabel('$x_i$')

 


plt.title(u'与linalg.lstsq匹配的数据',fontproperties=font_set)

 

plt.plot(xi,zi,'x',xi2,yi2)
plt.axes([0,1.1,3.0,5.5])

plt.show()

说明:红色部分是为了显示中文配置的,在mac机器上配置;

2.运行效果

matplotlib的编写画图中文forMac

 

 

相关文章:

  • 2021-09-05
  • 2021-08-19
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-18
  • 2021-06-26
  • 2022-12-23
  • 2021-03-29
  • 2021-05-16
  • 2021-06-27
相关资源
相似解决方案