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, zmax, 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 1311 of file plotting.py.

Constructor & Destructor Documentation

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

Definition at line 1313 of file plotting.py.

1313  def __init__(self, pad, bounds, zmax, ratioBounds, ratioFactor, nrows, xbinlabels=None, xbinlabelsize=None, xbinlabeloption=None, ratioYTitle=_ratioYTitle):
1314  self._parentPad = pad
1315  self._pad = pad.cd(1)
1316  if xbinlabels is not None:
1317  self._frame = _drawFrame(self._pad, bounds, zmax, [""]*len(xbinlabels))
1318  else:
1319  self._frame = _drawFrame(self._pad, bounds, zmax)
1320  self._padRatio = pad.cd(2)
1321  self._frameRatio = _drawFrame(self._padRatio, ratioBounds, zmax, xbinlabels, xbinlabelsize, xbinlabeloption)
1322 
1323  self._frame.GetXaxis().SetLabelSize(0)
1324  self._frame.GetXaxis().SetTitleSize(0)
1325 
1326  yoffsetFactor = ratioFactor
1327  divisionPoint = 1-1/ratioFactor
1328  xoffsetFactor = 1/divisionPoint #* 0.6
1329 
1330  if nrows == 1:
1331  xoffsetFactor *= 0.6
1332  elif nrows == 2:
1333  yoffsetFactor *= 2
1334  xoffsetFactor *= 1.5
1335  elif nrows == 3:
1336  yoffsetFactor *= 4
1337  xoffsetFactor *= 2.3
1338  elif nrows >= 4:
1339  yoffsetFactor *= 5
1340  xoffsetFactor *= 3
1341 
1342  self._frame.GetYaxis().SetTitleOffset(self._frameRatio.GetYaxis().GetTitleOffset()*yoffsetFactor)
1343  self._frameRatio.GetYaxis().SetLabelSize(int(self._frameRatio.GetYaxis().GetLabelSize()*0.8))
1344  self._frameRatio.GetYaxis().SetTitleOffset(self._frameRatio.GetYaxis().GetTitleOffset()*yoffsetFactor)
1345  self._frameRatio.GetXaxis().SetTitleOffset(self._frameRatio.GetXaxis().GetTitleOffset()*xoffsetFactor)
1346 
1347  self._frameRatio.GetYaxis().SetNdivisions(4, 5, 0)
1348 
1349  self._frameRatio.GetYaxis().SetTitle(ratioYTitle)
1350 
def _drawFrame(pad, bounds, zmax=None, xbinlabels=None, xbinlabelsize=None, xbinlabeloption=None, ybinlabels=None, suffix="")
Definition: plotting.py:1186
def __init__(self, pad, bounds, zmax, ratioBounds, ratioFactor, nrows, xbinlabels=None, xbinlabelsize=None, xbinlabeloption=None, ratioYTitle=_ratioYTitle)
Definition: plotting.py:1313

Member Function Documentation

def plotting.FrameRatio.adjustMarginLeft (   self,
  adjust 
)

Definition at line 1366 of file plotting.py.

1366  def adjustMarginLeft(self, adjust):
1367  self._pad.SetLeftMargin(self._pad.GetLeftMargin()+adjust)
1368  self._padRatio.SetLeftMargin(self._padRatio.GetLeftMargin()+adjust)
1369  # Need to redraw frame after adjusting the margin
1370  self._pad.cd()
1371  self._frame.Draw("")
1372  self._padRatio.cd()
1373  self._frameRatio.Draw("")
1374 
def adjustMarginLeft(self, adjust)
Definition: plotting.py:1366
def plotting.FrameRatio.adjustMarginRight (   self,
  adjust 
)

Definition at line 1375 of file plotting.py.

1375  def adjustMarginRight(self, adjust):
1376  self._pad.SetRightMargin(self._pad.GetRightMargin()+adjust)
1377  self._padRatio.SetRightMargin(self._padRatio.GetRightMargin()+adjust)
1378  # Need to redraw frames after adjusting the margin
1379  self._pad.cd()
1380  self._frame.Draw("")
1381  self._padRatio.cd()
1382  self._frameRatio.Draw("")
1383 
def adjustMarginRight(self, adjust)
Definition: plotting.py:1375
def plotting.FrameRatio.redrawAxis (   self)

Definition at line 1413 of file plotting.py.

1413  def redrawAxis(self):
1414  self._padRatio.RedrawAxis()
1415  self._pad.RedrawAxis()
1416 
1417  self._parentPad.cd()
1418 
1419  # pad to hide the lowest y axis label of the main pad
1420  xmin=0.065
1421  ymin=0.285
1422  xmax=0.128
1423  ymax=0.33
1424  self._coverPad = ROOT.TPad("coverpad", "coverpad", xmin, ymin, xmax, ymax)
1425  self._coverPad.SetBorderMode(0)
1426  self._coverPad.Draw()
1427 
1428  self._pad.cd()
1429  self._pad.Pop() # Move the first pad on top
1430 
def redrawAxis(self)
Definition: plotting.py:1413
def plotting.FrameRatio.setGridx (   self,
  grid 
)

Definition at line 1358 of file plotting.py.

1358  def setGridx(self, grid):
1359  self._pad.SetGridx(grid)
1360  self._padRatio.SetGridx(grid)
1361 
def setGridx(self, grid)
Definition: plotting.py:1358
def plotting.FrameRatio.setGridy (   self,
  grid 
)

Definition at line 1362 of file plotting.py.

1362  def setGridy(self, grid):
1363  self._pad.SetGridy(grid)
1364  self._padRatio.SetGridy(grid)
1365 
def setGridy(self, grid)
Definition: plotting.py:1362
def plotting.FrameRatio.setLogx (   self,
  log 
)

Definition at line 1351 of file plotting.py.

1351  def setLogx(self, log):
1352  self._pad.SetLogx(log)
1353  self._padRatio.SetLogx(log)
1354 
def setLogx(self, log)
Definition: plotting.py:1351
def plotting.FrameRatio.setLogy (   self,
  log 
)

Definition at line 1355 of file plotting.py.

1355  def setLogy(self, log):
1356  self._pad.SetLogy(log)
1357 
def setLogy(self, log)
Definition: plotting.py:1355
def plotting.FrameRatio.setTitle (   self,
  title 
)

Definition at line 1384 of file plotting.py.

1384  def setTitle(self, title):
1385  self._frame.SetTitle(title)
1386 
def setTitle(self, title)
Definition: plotting.py:1384
def plotting.FrameRatio.setXLabelSize (   self,
  size 
)

Definition at line 1396 of file plotting.py.

1396  def setXLabelSize(self, size):
1397  self._frameRatio.GetXaxis().SetLabelSize(size)
1398 
def setXLabelSize(self, size)
Definition: plotting.py:1396
def plotting.FrameRatio.setXTitle (   self,
  title 
)

Definition at line 1387 of file plotting.py.

1387  def setXTitle(self, title):
1388  self._frameRatio.GetXaxis().SetTitle(title)
1389 
def setXTitle(self, title)
Definition: plotting.py:1387
def plotting.FrameRatio.setXTitleOffset (   self,
  offset 
)

Definition at line 1393 of file plotting.py.

1393  def setXTitleOffset(self, offset):
1394  self._frameRatio.GetXaxis().SetTitleOffset(offset)
1395 
def setXTitleOffset(self, offset)
Definition: plotting.py:1393
def plotting.FrameRatio.setXTitleSize (   self,
  size 
)

Definition at line 1390 of file plotting.py.

1390  def setXTitleSize(self, size):
1391  self._frameRatio.GetXaxis().SetTitleSize(size)
1392 
def setXTitleSize(self, size)
Definition: plotting.py:1390
def plotting.FrameRatio.setYTitle (   self,
  title 
)

Definition at line 1399 of file plotting.py.

1399  def setYTitle(self, title):
1400  self._frame.GetYaxis().SetTitle(title)
1401 
def setYTitle(self, title)
Definition: plotting.py:1399
def plotting.FrameRatio.setYTitleOffset (   self,
  offset 
)

Definition at line 1409 of file plotting.py.

1409  def setYTitleOffset(self, offset):
1410  self._frame.GetYaxis().SetTitleOffset(offset)
1411  self._frameRatio.GetYaxis().SetTitleOffset(offset)
1412 
def setYTitleOffset(self, offset)
Definition: plotting.py:1409
def plotting.FrameRatio.setYTitleRatio (   self,
  title 
)

Definition at line 1402 of file plotting.py.

1402  def setYTitleRatio(self, title):
1403  self._frameRatio.GetYaxis().SetTitle(title)
1404 
def setYTitleRatio(self, title)
Definition: plotting.py:1402
def plotting.FrameRatio.setYTitleSize (   self,
  size 
)

Definition at line 1405 of file plotting.py.

1405  def setYTitleSize(self, size):
1406  self._frame.GetYaxis().SetTitleSize(size)
1407  self._frameRatio.GetYaxis().SetTitleSize(size)
1408 
def setYTitleSize(self, size)
Definition: plotting.py:1405

Member Data Documentation

plotting.FrameRatio._coverPad
private

Definition at line 1424 of file plotting.py.

plotting.FrameRatio._frame
private

Definition at line 1317 of file plotting.py.

plotting.FrameRatio._frameRatio
private

Definition at line 1321 of file plotting.py.

plotting.FrameRatio._pad
private

Definition at line 1315 of file plotting.py.

plotting.FrameRatio._padRatio
private

Definition at line 1320 of file plotting.py.

plotting.FrameRatio._parentPad
private

Definition at line 1314 of file plotting.py.