Find x-y axis boundaries encompassing a list of TH1s if the bounds are not given in arguments.
Arguments:
th1s -- List of TH1s
ylog -- Boolean indicating if y axis is in log scale or not (affects the automatic ymax)
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 138 of file plotting.py.
References _getXmax(), _getXmin(), _getYmax(), _getYmin(), _getYminIgnoreOutlier(), alcazmumu_cfi.filter, bookConverter.max, and min().
139 def _findBounds(th1s, ylog, xmin=None, xmax=None, ymin=None, ymax=None):
140 """Find x-y axis boundaries encompassing a list of TH1s if the bounds are not given in arguments.
144 ylog -- Boolean indicating if y axis is in log scale or not (affects the automatic ymax)
147 xmin -- Minimum x value; if None, take the minimum of TH1s
148 xmax -- Maximum x value; if None, take the maximum of TH1s
149 xmin -- Minimum y value; if None, take the minimum of TH1s
150 xmax -- Maximum y value; if None, take the maximum of TH1s
162 if xmin
is None or xmax
is None or ymin
is None or ymax
is None or \
163 isinstance(xmin, list)
or isinstance(max, list)
or isinstance(ymin, list)
or isinstance(ymax, list):
169 xmins.append(
_getXmin(th1, limitToNonZeroContent=isinstance(xmin, list)))
170 xmaxs.append(
_getXmax(th1, limitToNonZeroContent=isinstance(xmax, list)))
171 if ylog
and isinstance(ymin, list):
180 elif isinstance(xmin, list):
182 xmins_below =
filter(
lambda x: x<=xm, xmin)
183 if len(xmins_below) == 0:
187 print "Histogram minimum x %f is below all given xmin values %s, using the smallest one" % (xm, str(xmin))
189 xmin =
max(xmins_below)
193 elif isinstance(xmax, list):
195 xmaxs_above =
filter(
lambda x: x>xm, xmax)
196 if len(xmaxs_above) == 0:
200 print "Histogram maximum x %f is above all given xmax values %s, using the maximum one" % (xm, str(xmax))
202 xmax =
min(xmaxs_above)
206 elif isinstance(ymin, list):
207 ym_unscaled =
min(ymins)
208 ym = y_scale_min(ym_unscaled)
209 ymins_below =
filter(
lambda y: y<=ym, ymin)
210 if len(ymins_below) == 0:
212 if ym_unscaled < ymin:
214 print "Histogram minimum y %f is below all given ymin values %s, using the smallest one" % (ym, str(ymin))
216 ymin =
max(ymins_below)
219 ymax = y_scale_max(
max(ymaxs))
220 elif isinstance(ymax, list):
221 ym_unscaled =
max(ymaxs)
222 ym = y_scale_max(ym_unscaled)
223 ymaxs_above =
filter(
lambda y: y>ym, ymax)
224 if len(ymaxs_above) == 0:
226 if ym_unscaled > ymax:
228 print "Histogram maximum y %f is above all given ymax values %s, using the maximum one" % (ym_unscaled, str(ymax))
230 ymax =
min(ymaxs_above)
233 th1.GetXaxis().SetRangeUser(xmin, xmax)
234 th1.GetYaxis().SetRangeUser(ymin, ymax)
236 return (xmin, ymin, xmax, ymax)
def _getYminIgnoreOutlier