13 import matplotlib.pyplot
as plt
17 def histplot(data_x, data_y, error=None, label=None, **kwargs):
19 "xlabel" :
r"$p_T\:[GeV]$",
20 "ylabel":
'Efficiency',
22 "title1_1":
r"Simulation",
23 "title2":
r"$\sqrt{s}=13\:TeV$",
24 "filename":
"trunontest",
29 "errorbar_limit":
None,
31 for each_key
in kwargs.items():
32 settings[each_key[0]] = kwargs[each_key[0]]
33 plt.figure(figsize=(8, 6))
37 label = [
"a"] * len(data_x)
38 for i
in range(len(data_x)):
40 if settings[
"errorbar_limit"]
is not None:
42 for each_error, each_yi
in zip(error[i], data_y[i]):
44 if each_yi + each_error > settings[
"errorbar_limit"]:
45 uperror = settings[
"errorbar_limit"] - each_yi
46 allerror.append([each_error, uperror])
52 plt.errorbar(data_x[i], data_y[i], yerr=np.array(allerror).T, label=label[i], fmt=style)
54 plt.plot(data_x[i], data_y[i], label=label[i])
57 plt.legend(loc=
'upper right', prop={
'size': 25}, frameon=
False)
61 ax1.set_ylim([0,
max([y
for x
in data_y
for y
in x])* settings[
"upper_y"]])
62 ax1.text(0.05, 1.55 / 1.7, settings[
'title1'], fontsize=25, transform=ax1.transAxes, style=
'italic', fontweight=
'bold')
63 ax1.text(0.28, 1.55/ 1.7, settings[
'title1_1'], fontsize=25, transform=ax1.transAxes)
64 ax1.text(0.05, 1.40 / 1.7, settings[
'title2'], fontsize=23, transform=ax1.transAxes)
66 plt.tick_params(labelsize=16)
67 plt.tick_params(labelsize=16)
68 plt.ylabel(settings[
'ylabel'], fontsize=20)
69 plt.xlabel(settings[
'xlabel'], fontsize=20)
70 plt.savefig(settings[
'filename'] +
'.pdf', bbox_inches=
'tight')