ATLAS Offline Software
Functions
plotlib Namespace Reference

Functions

def histplot (data_x, data_y, error=None, label=None, **kwargs)
 

Function Documentation

◆ histplot()

def plotlib.histplot (   data_x,
  data_y,
  error = None,
  label = None,
**  kwargs 
)

Definition at line 18 of file plotlib.py.

18 def histplot(data_x, data_y, error=None, label=None, **kwargs):
19  settings = {
20  "xlabel" : r"$p_T\:[GeV]$",
21  "ylabel": 'Efficiency',
22  "title1": r"ATLAS",
23  "title1_1": r"Simulation",
24  "title2": r"$\sqrt{s}=13\:TeV$",
25  "filename": "trunontest",
26  "log_y":False,
27  "norm":False,
28  "scale":1,
29  "upper_y": 1.7,
30  "errorbar_limit": None,
31  }
32  for each_key in kwargs.items():
33  settings[each_key[0]] = kwargs[each_key[0]]
34  plt.figure(figsize=(8, 6))
35  remove_label = False
36  if label is None:
37  remove_label = True
38  label = ["a"] * len(data_x)
39  for i in range(len(data_x)):
40  if error is not None:
41  if settings["errorbar_limit"] is not None:
42  allerror = []
43  for each_error, each_yi in zip(error[i], data_y[i]):
44  uperror = each_error
45  if each_yi + each_error > settings["errorbar_limit"]:
46  uperror = settings["errorbar_limit"] - each_yi
47  allerror.append([each_error, uperror])
48  else:
49  allerror = error[i]
50  style = '.-'
51  if len(data_x) == 1:
52  style = 'k.-'
53  plt.errorbar(data_x[i], data_y[i], yerr=np.array(allerror).T, label=label[i], fmt=style)
54  else:
55  plt.plot(data_x[i], data_y[i], label=label[i])
56  ax1 = plt.gca()
57 
58  plt.legend(loc='upper right', prop={'size': 25}, frameon=False)
59  if remove_label:
60  ax1.get_legend().remove()
61 
62  ax1.set_ylim([0, max([y for x in data_y for y in x])* settings["upper_y"]])
63  ax1.text(0.05, 1.55 / 1.7, settings['title1'], fontsize=25, transform=ax1.transAxes, style='italic', fontweight='bold')
64  ax1.text(0.28, 1.55/ 1.7, settings['title1_1'], fontsize=25, transform=ax1.transAxes)
65  ax1.text(0.05, 1.40 / 1.7, settings['title2'], fontsize=23, transform=ax1.transAxes)
66 
67  plt.tick_params(labelsize=16)
68  plt.tick_params(labelsize=16)
69  plt.ylabel(settings['ylabel'], fontsize=20)
70  plt.xlabel(settings['xlabel'], fontsize=20)
71  plt.savefig(settings['filename'] + '.pdf', bbox_inches='tight')
72  plt.close()
max
#define max(a, b)
Definition: cfImp.cxx:41
PixelModuleFeMask_create_db.remove
string remove
Definition: PixelModuleFeMask_create_db.py:83
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
plotlib.histplot
def histplot(data_x, data_y, error=None, label=None, **kwargs)
Definition: plotlib.py:18