test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
plotting.FrameRatio Class Reference

Public Member Functions

def __init__
 
def adjustMarginLeft
 
def adjustMarginRight
 
def redrawAxis
 
def setGridx
 
def setGridy
 
def setLogx
 
def setLogy
 
def setTitle
 
def setXLabelSize
 
def setXTitle
 
def setXTitleOffset
 
def setXTitleSize
 
def setYTitle
 
def setYTitleOffset
 
def setYTitleRatio
 
def setYTitleSize
 

Private Attributes

 _coverPad
 
 _frame
 
 _frameRatio
 
 _pad
 
 _padRatio
 
 _parentPad
 

Detailed Description

Class for creating and managing a frame for a ratio plot with two subpads

Definition at line 1106 of file plotting.py.

Constructor & Destructor Documentation

def plotting.FrameRatio.__init__ (   self,
  pad,
  bounds,
  ratioBounds,
  ratioFactor,
  nrows,
  xbinlabels = None,
  xbinlabelsize = None,
  xbinlabeloption = None 
)

Definition at line 1108 of file plotting.py.

1109  def __init__(self, pad, bounds, ratioBounds, ratioFactor, nrows, xbinlabels=None, xbinlabelsize=None, xbinlabeloption=None):
1110  self._parentPad = pad
1111  self._pad = pad.cd(1)
1112  if xbinlabels is not None:
1113  self._frame = _drawFrame(self._pad, bounds, [""]*len(xbinlabels))
1114  else:
1115  self._frame = _drawFrame(self._pad, bounds)
1116  self._padRatio = pad.cd(2)
1117  self._frameRatio = _drawFrame(self._padRatio, ratioBounds, xbinlabels, xbinlabelsize, xbinlabeloption)
1118 
1119  self._frame.GetXaxis().SetLabelSize(0)
1120  self._frame.GetXaxis().SetTitleSize(0)
1121 
1122  yoffsetFactor = ratioFactor
1123  divisionPoint = 1-1/ratioFactor
1124  xoffsetFactor = 1/divisionPoint #* 0.6
1125 
1126  if nrows == 1:
1127  xoffsetFactor *= 0.6
1128  elif nrows == 2:
1129  yoffsetFactor *= 2
1130  xoffsetFactor *= 1.5
1131  elif nrows == 3:
1132  yoffsetFactor *= 4
1133  xoffsetFactor *= 2.3
1134  elif nrows >= 4:
1135  yoffsetFactor *= 5
1136  xoffsetFactor *= 3
1137 
1138  self._frame.GetYaxis().SetTitleOffset(self._frameRatio.GetYaxis().GetTitleOffset()*yoffsetFactor)
1139  self._frameRatio.GetYaxis().SetLabelSize(int(self._frameRatio.GetYaxis().GetLabelSize()*0.8))
1140  self._frameRatio.GetYaxis().SetTitleOffset(self._frameRatio.GetYaxis().GetTitleOffset()*yoffsetFactor)
1141  self._frameRatio.GetXaxis().SetTitleOffset(self._frameRatio.GetXaxis().GetTitleOffset()*xoffsetFactor)
1142 
1143  self._frameRatio.GetYaxis().SetNdivisions(4, 5, 0)
1144 
1145  self._frameRatio.GetYaxis().SetTitle(ratioYTitle)
def _drawFrame
Definition: plotting.py:1000

Member Function Documentation

def plotting.FrameRatio.adjustMarginLeft (   self,
  adjust 
)

Definition at line 1161 of file plotting.py.

1162  def adjustMarginLeft(self, adjust):
1163  self._pad.SetLeftMargin(self._pad.GetLeftMargin()+adjust)
1164  self._padRatio.SetLeftMargin(self._padRatio.GetLeftMargin()+adjust)
1165  # Need to redraw frame after adjusting the margin
1166  self._pad.cd()
1167  self._frame.Draw("")
1168  self._padRatio.cd()
1169  self._frameRatio.Draw("")
def plotting.FrameRatio.adjustMarginRight (   self,
  adjust 
)

Definition at line 1170 of file plotting.py.

1171  def adjustMarginRight(self, adjust):
1172  self._pad.SetRightMargin(self._pad.GetRightMargin()+adjust)
1173  self._padRatio.SetRightMargin(self._padRatio.GetRightMargin()+adjust)
1174  # Need to redraw frames after adjusting the margin
1175  self._pad.cd()
1176  self._frame.Draw("")
1177  self._padRatio.cd()
1178  self._frameRatio.Draw("")
def plotting.FrameRatio.redrawAxis (   self)

Definition at line 1208 of file plotting.py.

1209  def redrawAxis(self):
1210  self._padRatio.RedrawAxis()
1211  self._pad.RedrawAxis()
1212 
1213  self._parentPad.cd()
1214 
1215  # pad to hide the lowest y axis label of the main pad
1216  xmin=0.065
1217  ymin=0.285
1218  xmax=0.128
1219  ymax=0.33
1220  self._coverPad = ROOT.TPad("coverpad", "coverpad", xmin, ymin, xmax, ymax)
1221  self._coverPad.SetBorderMode(0)
1222  self._coverPad.Draw()
1223 
1224  self._pad.cd()
1225  self._pad.Pop() # Move the first pad on top
def plotting.FrameRatio.setGridx (   self,
  grid 
)

Definition at line 1153 of file plotting.py.

1154  def setGridx(self, grid):
1155  self._pad.SetGridx(grid)
1156  self._padRatio.SetGridx(grid)
def plotting.FrameRatio.setGridy (   self,
  grid 
)

Definition at line 1157 of file plotting.py.

1158  def setGridy(self, grid):
1159  self._pad.SetGridy(grid)
1160  self._padRatio.SetGridy(grid)
def plotting.FrameRatio.setLogx (   self,
  log 
)

Definition at line 1146 of file plotting.py.

1147  def setLogx(self, log):
1148  self._pad.SetLogx(log)
1149  self._padRatio.SetLogx(log)
def plotting.FrameRatio.setLogy (   self,
  log 
)

Definition at line 1150 of file plotting.py.

1151  def setLogy(self, log):
1152  self._pad.SetLogy(log)
def plotting.FrameRatio.setTitle (   self,
  title 
)

Definition at line 1179 of file plotting.py.

1180  def setTitle(self, title):
1181  self._frame.SetTitle(title)
def plotting.FrameRatio.setXLabelSize (   self,
  size 
)

Definition at line 1191 of file plotting.py.

1192  def setXLabelSize(self, size):
1193  self._frameRatio.GetXaxis().SetLabelSize(size)
def plotting.FrameRatio.setXTitle (   self,
  title 
)

Definition at line 1182 of file plotting.py.

1183  def setXTitle(self, title):
1184  self._frameRatio.GetXaxis().SetTitle(title)
def plotting.FrameRatio.setXTitleOffset (   self,
  offset 
)

Definition at line 1188 of file plotting.py.

1189  def setXTitleOffset(self, offset):
1190  self._frameRatio.GetXaxis().SetTitleOffset(offset)
def plotting.FrameRatio.setXTitleSize (   self,
  size 
)

Definition at line 1185 of file plotting.py.

1186  def setXTitleSize(self, size):
1187  self._frameRatio.GetXaxis().SetTitleSize(size)
def plotting.FrameRatio.setYTitle (   self,
  title 
)

Definition at line 1194 of file plotting.py.

1195  def setYTitle(self, title):
1196  self._frame.GetYaxis().SetTitle(title)
def plotting.FrameRatio.setYTitleOffset (   self,
  offset 
)

Definition at line 1204 of file plotting.py.

1205  def setYTitleOffset(self, offset):
1206  self._frame.GetYaxis().SetTitleOffset(offset)
1207  self._frameRatio.GetYaxis().SetTitleOffset(offset)
def plotting.FrameRatio.setYTitleRatio (   self,
  title 
)

Definition at line 1197 of file plotting.py.

1198  def setYTitleRatio(self, title):
1199  self._frameRatio.GetYaxis().SetTitle(title)
def plotting.FrameRatio.setYTitleSize (   self,
  size 
)

Definition at line 1200 of file plotting.py.

1201  def setYTitleSize(self, size):
1202  self._frame.GetYaxis().SetTitleSize(size)
1203  self._frameRatio.GetYaxis().SetTitleSize(size)

Member Data Documentation

plotting.FrameRatio._coverPad
private

Definition at line 1219 of file plotting.py.

plotting.FrameRatio._frame
private

Definition at line 1112 of file plotting.py.

plotting.FrameRatio._frameRatio
private

Definition at line 1116 of file plotting.py.

plotting.FrameRatio._pad
private

Definition at line 1110 of file plotting.py.

plotting.FrameRatio._padRatio
private

Definition at line 1115 of file plotting.py.

plotting.FrameRatio._parentPad
private

Definition at line 1109 of file plotting.py.