用python画累积累计曲线的脚本

在处理数据时,我们经常需要去分析 累计分布:

def plohist(filec, num_bin, xlabel):
	dataset=pd.read_csv(path+filec,header=None,sep=' +',engine='python'); counts=[]; counts.extend(dataset.values[:,0]);
	fig=plt.figure(figsize=(15,10),dpi=80); ax1=fig.add_subplot(111); ax2=ax1.twinx()
	myfont=mpl.font_manager.FontProperties(fname='C:\Windows\Fonts\simsun.ttc', size=30) #标签字体
	mpl.rcParams.update({'font.size': 20}) # 改变刻度所有字体大小,改变其他性质类似
	mpl.rcParams['xtick.direction'] = 'in'
	mpl.rcParams['ytick.direction'] = 'in'
	n, bins, patches = ax1.hist(counts, num_bin, rwidth=5, color='cyan', edgecolor='black', hatch='///', label="counts",); ax1.legend(loc='upper left')
#	ax1.set_xticks(bins,rotation=60)
	ax1.set_xlabel(xlabel); ax1.set_ylabel('counts');
	acc = [sum(n[:i])/len(counts) for i in range(len(n)+1)]
	ax2.plot(bins, acc, 'ro-', color='red', label="CDF"); ax2.legend(loc='upper right'); 
	ax2.set_ylabel('CDF(%)'); ax2.set_ylim(0,1.1); #ax2.set_xlim(xlim1,xlim2);
	ax2.grid(color='grey',linestyle='-.')
	plt.savefig(path+xlabel[0:3]+'.png')
#	plt.show()
#	return n,bins,patches
plohist('bPwv.dat', 22, 'PWV(mm)')

参考:https://blog.csdn.net/qq_37948866/article/details/104102877

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

蜡木浦

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值