当前位置:
凯发ag旗舰厅登录网址下载 >
编程语言
> python
>内容正文
python
用python的matplotlib画标准正态曲线 -凯发ag旗舰厅登录网址下载
凯发ag旗舰厅登录网址下载
收集整理的这篇文章主要介绍了
用python的matplotlib画标准正态曲线
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
先看实现的效果,有一个形象的认识。
这样一副图怎么画出来呢?
用python将变得很简单,看代码吧!
import math import pylab as pl import numpy as np def gd(x,m,s):left=1/(math.sqrt(2*math.pi)*s)right=math.exp(-math.pow(x-m,2)/(2*math.pow(s,2)))return left*right def showfigure():x=np.arange(-4,5,0.1)y=[]for i in x:y.append(gd(i,0,1))pl.plot(x,y) pl.xlim(-4.0,5.0)pl.ylim(-0.2,0.5) #ax = pl.gca()ax.spines['right'].set_color('none')ax.spines['top'].set_color('none')ax.xaxis.set_ticks_position('bottom')ax.spines['bottom'].set_position(('data',0))ax.yaxis.set_ticks_position('left')ax.spines['left'].set_position(('data',0))#add paramlabel_f1 = "$\mu=0,\ \sigma=1$"pl.text(2.5,0.3,label_f1,fontsize=15,verticalalignment="top",horizontalalignment="left")label_f2 = r"$f(x)=\frac{1}{\sqrt{2\pi}\sigma}exp(-\frac{(x-\mu)^2}{2\sigma^2})$"pl.text(1.5,0.4,label_f2,fontsize=15,verticalalignment="top",horizontalalignment="left")pl.show()
总结
以上是凯发ag旗舰厅登录网址下载为你收集整理的用python的matplotlib画标准正态曲线的全部内容,希望文章能够帮你解决所遇到的问题。
如果觉得凯发ag旗舰厅登录网址下载网站内容还不错,欢迎将凯发ag旗舰厅登录网址下载推荐给好友。
- 上一篇: 高清精美壁纸:2013年9月桌面日历壁纸
- 下一篇: [worldwind学习]18.high