帮朋友画个图

帮朋友画了两张统计图,代码与图片如下:
(本来在挣扎着写积分上限函数的,突然发现这俩函数居然在math库里…)

import matplotlib.pyplot as plt
import numpy as np
import math
plt.rcParams['font.sans-serif'] = ['SimHei'] 
plt.rcParams['axes.unicode_minus'] = False 

第一张:

x = np.arange(-10, 10, 0.01)
y1 = [math.erfc(a) for a in x]
y2 = [math.erf(a) for a in x]
plt.xlabel('x')
plt.ylabel('f(x)')
plt.title("误差函数与余误差函数图像")
plt.plot(x, y1)
plt.plot(x,y2,linestyle='dashed')
plt.legend(['erfc(x)','erf(x)'])
plt.savefig("误差函数与余误差函数图像.jpg",dpi=500)
plt.show()


第二张:

x = np.arange(0.05, 1, 0.001)
y3 = [math.exp(-a*a)/(math.sqrt(math.pi)*a)-math.erfc(a) for a in x]
plt.xlabel('x')
plt.ylabel('Dq(x)')
plt.title("定流量沟函数图像")
plt.plot(x, y3)
plt.savefig("定流量沟函数图像.jpg",dpi=500)
plt.show()

Guess you like

Origin blog.csdn.net/qq_51007395/article/details/121917803