def graphing(what, data, who):
kek = data[who][what]
fig = figure()
ax = fig.add_subplot(111)
if '\xa0' in str(kek):
kek = (int(kek.replace(u'\xa0', '')))
data = stuff[what]
mean, sigma = norm.fit(data)
plt.hist(data, bins = 1000, normed=True, alpha=0.4)
xmin, xmax = plt.xlim()
x = np.linspace(xmin, xmax, 1000)
p = norm.pdf(x, mean, sigma)
plt.plot(x, p, 'k', linewidth=2)
title = f'{what}\nFit results: mean = {round(mean,2)}, sigma = {round(sigma,2)}'
plt.title(title)
two, eight = norm.interval(.999, loc = mean, scale = sigma)
plt.xlim(0, eight)
new = norm.pdf(kek, mean, sigma)
plt.plot([kek, kek], [0, new], color='r', linestyle='--')
if what == 'Death/Game':
at = round((1-norm.cdf(kek, mean, sigma))*100, 2)
else:
at = round(norm.cdf(kek, mean, sigma)*100, 2)
text = f'You are better than \n{at}% players'
ax.annotate(text, xy=(kek, new), xytext=(0.7, 0.8), textcoords='axes fraction',
arrowprops=dict(facecolor='g', color='g'))
what = what.replace('/', '-')
#plt.show()
plt.savefig(f'Y:/python/graphs/data/{what}.png')
#plt.close()
评论列表
文章目录