CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
plotting.FrameRatio Class Reference

Public Member Functions

def __init__ (self, pad, bounds, ratioBounds, ratioFactor, nrows, xbinlabels=None, xbinlabelsize=None, xbinlabeloption=None, ratioYTitle=_ratioYTitle)
 
def adjustMarginLeft (self, adjust)
 
def adjustMarginRight (self, adjust)
 
def redrawAxis (self)
 
def setGridx (self, grid)
 
def setGridy (self, grid)
 
def setLogx (self, log)
 
def setLogy (self, log)
 
def setTitle (self, title)
 
def setXLabelSize (self, size)
 
def setXTitle (self, title)
 
def setXTitleOffset (self, offset)
 
def setXTitleSize (self, size)
 
def setYTitle (self, title)
 
def setYTitleOffset (self, offset)
 
def setYTitleRatio (self, title)
 
def setYTitleSize (self, size)
 

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 1124 of file plotting.py.

Constructor & Destructor Documentation

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

Definition at line 1126 of file plotting.py.

1126  def __init__(self, pad, bounds, ratioBounds, ratioFactor, nrows, xbinlabels=None, xbinlabelsize=None, xbinlabeloption=None, ratioYTitle=_ratioYTitle):
1127  self._parentPad = pad
1128  self._pad = pad.cd(1)
1129  if xbinlabels is not None:
1130  self._frame = _drawFrame(self._pad, bounds, [""]*len(xbinlabels))
1131  else:
1132  self._frame = _drawFrame(self._pad, bounds)
1133  self._padRatio = pad.cd(2)
1134  self._frameRatio = _drawFrame(self._padRatio, ratioBounds, xbinlabels, xbinlabelsize, xbinlabeloption)
1135 
1136  self._frame.GetXaxis().SetLabelSize(0)
1137  self._frame.GetXaxis().SetTitleSize(0)
1138 
1139  yoffsetFactor = ratioFactor
1140  divisionPoint = 1-1/ratioFactor
1141  xoffsetFactor = 1/divisionPoint #* 0.6
1142 
1143  if nrows == 1:
1144  xoffsetFactor *= 0.6
1145  elif nrows == 2:
1146  yoffsetFactor *= 2
1147  xoffsetFactor *= 1.5
1148  elif nrows == 3:
1149  yoffsetFactor *= 4
1150  xoffsetFactor *= 2.3
1151  elif nrows >= 4:
1152  yoffsetFactor *= 5
1153  xoffsetFactor *= 3
1154 
1155  self._frame.GetYaxis().SetTitleOffset(self._frameRatio.GetYaxis().GetTitleOffset()*yoffsetFactor)
1156  self._frameRatio.GetYaxis().SetLabelSize(int(self._frameRatio.GetYaxis().GetLabelSize()*0.8))
1157  self._frameRatio.GetYaxis().SetTitleOffset(self._frameRatio.GetYaxis().GetTitleOffset()*yoffsetFactor)
1158  self._frameRatio.GetXaxis().SetTitleOffset(self._frameRatio.GetXaxis().GetTitleOffset()*xoffsetFactor)
1159 
1160  self._frameRatio.GetYaxis().SetNdivisions(4, 5, 0)
1161 
1162  self._frameRatio.GetYaxis().SetTitle(ratioYTitle)
1163 
def __init__(self, pad, bounds, ratioBounds, ratioFactor, nrows, xbinlabels=None, xbinlabelsize=None, xbinlabeloption=None, ratioYTitle=_ratioYTitle)
Definition: plotting.py:1126
def _drawFrame(pad, bounds, xbinlabels=None, xbinlabelsize=None, xbinlabeloption=None, suffix="")
Definition: plotting.py:1018

Member Function Documentation

def plotting.FrameRatio.adjustMarginLeft (   self,
  adjust 
)

Definition at line 1179 of file plotting.py.

1179  def adjustMarginLeft(self, adjust):
1180  self._pad.SetLeftMargin(self._pad.GetLeftMargin()+adjust)
1181  self._padRatio.SetLeftMargin(self._padRatio.GetLeftMargin()+adjust)
1182  # Need to redraw frame after adjusting the margin
1183  self._pad.cd()
1184  self._frame.Draw("")
1185  self._padRatio.cd()
1186  self._frameRatio.Draw("")
1187 
def adjustMarginLeft(self, adjust)
Definition: plotting.py:1179
def plotting.FrameRatio.adjustMarginRight (   self,
  adjust 
)

Definition at line 1188 of file plotting.py.

1188  def adjustMarginRight(self, adjust):
1189  self._pad.SetRightMargin(self._pad.GetRightMargin()+adjust)
1190  self._padRatio.SetRightMargin(self._padRatio.GetRightMargin()+adjust)
1191  # Need to redraw frames after adjusting the margin
1192  self._pad.cd()
1193  self._frame.Draw("")
1194  self._padRatio.cd()
1195  self._frameRatio.Draw("")
1196 
def adjustMarginRight(self, adjust)
Definition: plotting.py:1188
def plotting.FrameRatio.redrawAxis (   self)

Definition at line 1226 of file plotting.py.

1226  def redrawAxis(self):
1227  self._padRatio.RedrawAxis()
1228  self._pad.RedrawAxis()
1229 
1230  self._parentPad.cd()
1231 
1232  # pad to hide the lowest y axis label of the main pad
1233  xmin=0.065
1234  ymin=0.285
1235  xmax=0.128
1236  ymax=0.33
1237  self._coverPad = ROOT.TPad("coverpad", "coverpad", xmin, ymin, xmax, ymax)
1238  self._coverPad.SetBorderMode(0)
1239  self._coverPad.Draw()
1240 
1241  self._pad.cd()
1242  self._pad.Pop() # Move the first pad on top
1243 
def redrawAxis(self)
Definition: plotting.py:1226
def plotting.FrameRatio.setGridx (   self,
  grid 
)

Definition at line 1171 of file plotting.py.

1171  def setGridx(self, grid):
1172  self._pad.SetGridx(grid)
1173  self._padRatio.SetGridx(grid)
1174 
def setGridx(self, grid)
Definition: plotting.py:1171
def plotting.FrameRatio.setGridy (   self,
  grid 
)

Definition at line 1175 of file plotting.py.

1175  def setGridy(self, grid):
1176  self._pad.SetGridy(grid)
1177  self._padRatio.SetGridy(grid)
1178 
def setGridy(self, grid)
Definition: plotting.py:1175
def plotting.FrameRatio.setLogx (   self,
  log 
)

Definition at line 1164 of file plotting.py.

1164  def setLogx(self, log):
1165  self._pad.SetLogx(log)
1166  self._padRatio.SetLogx(log)
1167 
def setLogx(self, log)
Definition: plotting.py:1164
def plotting.FrameRatio.setLogy (   self,
  log 
)

Definition at line 1168 of file plotting.py.

1168  def setLogy(self, log):
1169  self._pad.SetLogy(log)
1170 
def setLogy(self, log)
Definition: plotting.py:1168
def plotting.FrameRatio.setTitle (   self,
  title 
)

Definition at line 1197 of file plotting.py.

1197  def setTitle(self, title):
1198  self._frame.SetTitle(title)
1199 
def setTitle(self, title)
Definition: plotting.py:1197
def plotting.FrameRatio.setXLabelSize (   self,
  size 
)

Definition at line 1209 of file plotting.py.

1209  def setXLabelSize(self, size):
1210  self._frameRatio.GetXaxis().SetLabelSize(size)
1211 
def setXLabelSize(self, size)
Definition: plotting.py:1209
def plotting.FrameRatio.setXTitle (   self,
  title 
)

Definition at line 1200 of file plotting.py.

1200  def setXTitle(self, title):
1201  self._frameRatio.GetXaxis().SetTitle(title)
1202 
def setXTitle(self, title)
Definition: plotting.py:1200
def plotting.FrameRatio.setXTitleOffset (   self,
  offset 
)

Definition at line 1206 of file plotting.py.

1206  def setXTitleOffset(self, offset):
1207  self._frameRatio.GetXaxis().SetTitleOffset(offset)
1208 
def setXTitleOffset(self, offset)
Definition: plotting.py:1206
def plotting.FrameRatio.setXTitleSize (   self,
  size 
)

Definition at line 1203 of file plotting.py.

1203  def setXTitleSize(self, size):
1204  self._frameRatio.GetXaxis().SetTitleSize(size)
1205 
def setXTitleSize(self, size)
Definition: plotting.py:1203
def plotting.FrameRatio.setYTitle (   self,
  title 
)

Definition at line 1212 of file plotting.py.

1212  def setYTitle(self, title):
1213  self._frame.GetYaxis().SetTitle(title)
1214 
def setYTitle(self, title)
Definition: plotting.py:1212
def plotting.FrameRatio.setYTitleOffset (   self,
  offset 
)

Definition at line 1222 of file plotting.py.

1222  def setYTitleOffset(self, offset):
1223  self._frame.GetYaxis().SetTitleOffset(offset)
1224  self._frameRatio.GetYaxis().SetTitleOffset(offset)
1225 
def setYTitleOffset(self, offset)
Definition: plotting.py:1222
def plotting.FrameRatio.setYTitleRatio (   self,
  title 
)

Definition at line 1215 of file plotting.py.

1215  def setYTitleRatio(self, title):
1216  self._frameRatio.GetYaxis().SetTitle(title)
1217 
def setYTitleRatio(self, title)
Definition: plotting.py:1215
def plotting.FrameRatio.setYTitleSize (   self,
  size 
)

Definition at line 1218 of file plotting.py.

1218  def setYTitleSize(self, size):
1219  self._frame.GetYaxis().SetTitleSize(size)
1220  self._frameRatio.GetYaxis().SetTitleSize(size)
1221 
def setYTitleSize(self, size)
Definition: plotting.py:1218

Member Data Documentation

plotting.FrameRatio._coverPad
private

Definition at line 1237 of file plotting.py.

plotting.FrameRatio._frame
private

Definition at line 1130 of file plotting.py.

plotting.FrameRatio._frameRatio
private

Definition at line 1134 of file plotting.py.

plotting.FrameRatio._pad
private

Definition at line 1128 of file plotting.py.

plotting.FrameRatio._padRatio
private

Definition at line 1133 of file plotting.py.

plotting.FrameRatio._parentPad
private

Definition at line 1127 of file plotting.py.