Find x-y axis boundaries encompassing a list of TH1s if the bounds are not given in arguments.
Arguments:
th1s -- List of TH1s
Keyword arguments:
xmin -- Minimum x value; if None, take the minimum of TH1s
xmax -- Maximum x value; if None, take the maximum of TH1s
xmin -- Minimum y value; if None, take the minimum of TH1s
xmax -- Maximum y value; if None, take the maximum of TH1s
Definition at line 46 of file plotting.py.
References alcazmumu_cfi.filter, bookConverter.max, and min().
Referenced by plotting.Plot.draw().
47 def _findBounds(th1s, xmin=None, xmax=None, ymin=None, ymax=None):
48 """Find x-y axis boundaries encompassing a list of TH1s if the bounds are not given in arguments.
54 xmin -- Minimum x value; if None, take the minimum of TH1s
55 xmax -- Maximum x value; if None, take the maximum of TH1s
56 xmin -- Minimum y value; if None, take the minimum of TH1s
57 xmax -- Maximum y value; if None, take the maximum of TH1s
59 if xmin
is None or xmax
is None or ymin
is None or ymax
is None or isinstance(ymax, list):
65 xaxis = th1.GetXaxis()
66 xmins.append(xaxis.GetBinLowEdge(xaxis.GetFirst()))
67 xmaxs.append(xaxis.GetBinUpEdge(xaxis.GetLast()))
68 ymins.append(th1.GetMinimum())
69 ymaxs.append(th1.GetMaximum())
79 ymax = 1.05*
max(ymaxs)
80 elif isinstance(ymax, list):
82 ymaxs_above =
filter(
lambda y: y>ym, ymax)
83 if len(ymaxs_above) == 0:
84 raise Exception(
"Histogram maximum y %f is above all given ymax values %s" % (ym, str(ymax)))
85 ymax =
min(ymaxs_above)
88 th1.GetXaxis().SetRangeUser(xmin, xmax)
89 th1.GetYaxis().SetRangeUser(ymin, ymax)
91 return (xmin, ymin, xmax, ymax)