analistica/ex-4/plot.py

43 lines
922 B
Python
Executable File

#!/usr/bin/env python
import matplotlib.pyplot as plt
import numpy as np
import sys
def f(x, p_max):
return x * np.log(p_max/x)/np.arctan(np.sqrt(p_max**2/x**2 - 1))
def main():
bins = input()
step = input()
bins = int(bins.split("\t")[1])
step = float(step.split("\t")[1])
counts = np.loadtxt(sys.stdin)
edges = np.linspace(0, bins*step, bins+1)
plt.figure()
# plt.figure(figsize=(5, 3))
# plt.rcParams['font.size'] = 8
plt.hist(edges[:-1], edges, weights=counts,
histtype='stepfilled', color='#e3c5ca', edgecolor='#92182b')
plt.title('Simulation', loc='right')
plt.xlabel(r'$p_h$')
plt.ylabel(r'$\left<|p_v|\right>$')
# x = np.arange(0, 10, 0.001)
# y = f(x, 10)
# plt.plot(x, y, c='#92182b', linewidth=2)
plt.tight_layout()
plt.show()
# plt.savefig('notes/images/4-fit.pdf')
if __name__ == '__main__':
main()