CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions | Variables
plotting Namespace Reference

Classes

class  AggregateBins
 
class  AggregateHistos
 
class  AlgoOpt
 
class  FakeDuplicate
 
class  Plot
 
class  PlotGroup
 
class  Plotter
 

Functions

def _findBounds
 
def _getObject
 
def _getYmaxWithError
 

Variables

list _plotStylesColor = [4, 2, ROOT.kBlack, ROOT.kOrange+7, ROOT.kMagenta-3]
 
list _plotStylesMarker = [21, 20, 22, 34, 33]
 
 missingOk = False
 

Function Documentation

def plotting._findBounds (   th1s,
  xmin = None,
  xmax = None,
  ymin = None,
  ymax = None 
)
private
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().

46 
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.
49 
50  Arguments:
51  th1s -- List of TH1s
52 
53  Keyword 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
58  """
59  if xmin is None or xmax is None or ymin is None or ymax is None or isinstance(ymax, list):
60  xmins = []
61  xmaxs = []
62  ymins = []
63  ymaxs = []
64  for th1 in th1s:
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())
70 # ymaxs.append(_getYmaxWithError(th1))
71 
72  if xmin is None:
73  xmin = min(xmins)
74  if xmax is None:
75  xmax = max(xmaxs)
76  if ymin is None:
77  ymin = min(ymins)
78  if ymax is None:
79  ymax = 1.05*max(ymaxs)
80  elif isinstance(ymax, list):
81  ym = max(ymaxs)
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)
86 
87  for th1 in th1s:
88  th1.GetXaxis().SetRangeUser(xmin, xmax)
89  th1.GetYaxis().SetRangeUser(ymin, ymax)
90 
91  return (xmin, ymin, xmax, ymax)
92 
def _findBounds
Definition: plotting.py:46
T min(T a, T b)
Definition: MathUtil.h:58
def plotting._getObject (   tdirectory,
  name 
)
private

Definition at line 32 of file plotting.py.

Referenced by plotting.FakeDuplicate.create(), plotting.AggregateBins.create(), and plotting.AggregateHistos.create().

32 
33 def _getObject(tdirectory, name):
34  obj = tdirectory.Get(name)
35  if not obj:
36  print "Did not find {obj} from {dir}".format(obj=name, dir=tdirectory.GetPath())
37  if missingOk:
38  return None
39  else:
40  sys.exit(1)
41  return obj
42 
def _getObject
Definition: plotting.py:32
def plotting._getYmaxWithError (   th1)
private

Definition at line 43 of file plotting.py.

References bookConverter.max.

43 
44 def _getYmaxWithError(th1):
45  return max([th1.GetBinContent(i)+th1.GetBinError(i) for i in xrange(1, th1.GetNbinsX()+1)])
def _getYmaxWithError
Definition: plotting.py:43

Variable Documentation

list plotting._plotStylesColor = [4, 2, ROOT.kBlack, ROOT.kOrange+7, ROOT.kMagenta-3]

Definition at line 228 of file plotting.py.

list plotting._plotStylesMarker = [21, 20, 22, 34, 33]

Definition at line 229 of file plotting.py.

plotting.missingOk = False

Definition at line 10 of file plotting.py.