CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 1312 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 1314 of file plotting.py.

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

Member Function Documentation

def plotting.FrameRatio.adjustMarginLeft (   self,
  adjust 
)

Definition at line 1367 of file plotting.py.

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

Definition at line 1376 of file plotting.py.

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

Definition at line 1414 of file plotting.py.

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

Definition at line 1359 of file plotting.py.

1360  def setGridx(self, grid):
1361  self._pad.SetGridx(grid)
1362  self._padRatio.SetGridx(grid)
def plotting.FrameRatio.setGridy (   self,
  grid 
)

Definition at line 1363 of file plotting.py.

1364  def setGridy(self, grid):
1365  self._pad.SetGridy(grid)
1366  self._padRatio.SetGridy(grid)
def plotting.FrameRatio.setLogx (   self,
  log 
)

Definition at line 1352 of file plotting.py.

1353  def setLogx(self, log):
1354  self._pad.SetLogx(log)
1355  self._padRatio.SetLogx(log)
def plotting.FrameRatio.setLogy (   self,
  log 
)

Definition at line 1356 of file plotting.py.

1357  def setLogy(self, log):
1358  self._pad.SetLogy(log)
def plotting.FrameRatio.setTitle (   self,
  title 
)

Definition at line 1385 of file plotting.py.

1386  def setTitle(self, title):
1387  self._frame.SetTitle(title)
def plotting.FrameRatio.setXLabelSize (   self,
  size 
)

Definition at line 1397 of file plotting.py.

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

Definition at line 1388 of file plotting.py.

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

Definition at line 1394 of file plotting.py.

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

Definition at line 1391 of file plotting.py.

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

Definition at line 1400 of file plotting.py.

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

Definition at line 1410 of file plotting.py.

1411  def setYTitleOffset(self, offset):
1412  self._frame.GetYaxis().SetTitleOffset(offset)
1413  self._frameRatio.GetYaxis().SetTitleOffset(offset)
def plotting.FrameRatio.setYTitleRatio (   self,
  title 
)

Definition at line 1403 of file plotting.py.

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

Definition at line 1406 of file plotting.py.

1407  def setYTitleSize(self, size):
1408  self._frame.GetYaxis().SetTitleSize(size)
1409  self._frameRatio.GetYaxis().SetTitleSize(size)

Member Data Documentation

plotting.FrameRatio._coverPad
private

Definition at line 1425 of file plotting.py.

plotting.FrameRatio._frame
private

Definition at line 1318 of file plotting.py.

plotting.FrameRatio._frameRatio
private

Definition at line 1322 of file plotting.py.

plotting.FrameRatio._pad
private

Definition at line 1316 of file plotting.py.

plotting.FrameRatio._padRatio
private

Definition at line 1321 of file plotting.py.

plotting.FrameRatio._parentPad
private

Definition at line 1315 of file plotting.py.