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

Constructor & Destructor Documentation

◆ __init__()

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.

1314  def __init__(self, pad, bounds, zmax, ratioBounds, ratioFactor, nrows, xbinlabels=None, xbinlabelsize=None, xbinlabeloption=None, ratioYTitle=_ratioYTitle):
1315  self._parentPad = pad
1316  self._pad = pad.cd(1)
1317  if xbinlabels is not None:
1318  self._frame = _drawFrame(self._pad, bounds, zmax, [""]*len(xbinlabels))
1319  else:
1320  self._frame = _drawFrame(self._pad, bounds, zmax)
1321  self._padRatio = pad.cd(2)
1322  self._frameRatio = _drawFrame(self._padRatio, ratioBounds, zmax, xbinlabels, xbinlabelsize, xbinlabeloption)
1323 
1324  self._frame.GetXaxis().SetLabelSize(0)
1325  self._frame.GetXaxis().SetTitleSize(0)
1326 
1327  yoffsetFactor = ratioFactor
1328  divisionPoint = 1-1/ratioFactor
1329  xoffsetFactor = 1/divisionPoint #* 0.6
1330 
1331  if nrows == 1:
1332  xoffsetFactor *= 0.6
1333  elif nrows == 2:
1334  yoffsetFactor *= 2
1335  xoffsetFactor *= 1.5
1336  elif nrows == 3:
1337  yoffsetFactor *= 4
1338  xoffsetFactor *= 2.3
1339  elif nrows >= 4:
1340  yoffsetFactor *= 5
1341  xoffsetFactor *= 3
1342 
1343  self._frame.GetYaxis().SetTitleOffset(self._frameRatio.GetYaxis().GetTitleOffset()*yoffsetFactor)
1344  self._frameRatio.GetYaxis().SetLabelSize(int(self._frameRatio.GetYaxis().GetLabelSize()*0.8))
1345  self._frameRatio.GetYaxis().SetTitleOffset(self._frameRatio.GetYaxis().GetTitleOffset()*yoffsetFactor)
1346  self._frameRatio.GetXaxis().SetTitleOffset(self._frameRatio.GetXaxis().GetTitleOffset()*xoffsetFactor)
1347 
1348  self._frameRatio.GetYaxis().SetNdivisions(4, 5, 0)
1349 
1350  self._frameRatio.GetYaxis().SetTitle(ratioYTitle)
1351 
def _drawFrame(pad, bounds, zmax=None, xbinlabels=None, xbinlabelsize=None, xbinlabeloption=None, ybinlabels=None, suffix="")
Definition: plotting.py:1187
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)

Member Function Documentation

◆ adjustMarginLeft()

def plotting.FrameRatio.adjustMarginLeft (   self,
  adjust 
)

Definition at line 1367 of file plotting.py.

References plotting.Frame._frame, plotting.FrameRatio._frame, plotting.FrameRatio._frameRatio, plotting.Frame._pad, plotting.FrameRatio._pad, plotting.FrameRatio._padRatio, and hippyaddtobaddatafiles.cd().

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

◆ adjustMarginRight()

def plotting.FrameRatio.adjustMarginRight (   self,
  adjust 
)

Definition at line 1376 of file plotting.py.

References plotting.Frame._frame, plotting.FrameRatio._frame, plotting.FrameRatio._frameRatio, plotting.Frame._pad, plotting.FrameRatio._pad, plotting.FrameRatio._padRatio, and hippyaddtobaddatafiles.cd().

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

◆ redrawAxis()

def plotting.FrameRatio.redrawAxis (   self)

Definition at line 1414 of file plotting.py.

References plotting.Frame._pad, plotting.FrameRatio._pad, plotting.FrameRatio._padRatio, plotting.FrameRatio._parentPad, and hippyaddtobaddatafiles.cd().

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

◆ setGridx()

def plotting.FrameRatio.setGridx (   self,
  grid 
)

Definition at line 1359 of file plotting.py.

References plotting.Frame._pad, plotting.FrameRatio._pad, and plotting.FrameRatio._padRatio.

1359  def setGridx(self, grid):
1360  self._pad.SetGridx(grid)
1361  self._padRatio.SetGridx(grid)
1362 

◆ setGridy()

def plotting.FrameRatio.setGridy (   self,
  grid 
)

Definition at line 1363 of file plotting.py.

References plotting.Frame._pad, plotting.FrameRatio._pad, and plotting.FrameRatio._padRatio.

1363  def setGridy(self, grid):
1364  self._pad.SetGridy(grid)
1365  self._padRatio.SetGridy(grid)
1366 

◆ setLogx()

def plotting.FrameRatio.setLogx (   self,
  log 
)

Definition at line 1352 of file plotting.py.

References plotting.Frame._pad, plotting.FrameRatio._pad, and plotting.FrameRatio._padRatio.

1352  def setLogx(self, log):
1353  self._pad.SetLogx(log)
1354  self._padRatio.SetLogx(log)
1355 

◆ setLogy()

def plotting.FrameRatio.setLogy (   self,
  log 
)

Definition at line 1356 of file plotting.py.

References plotting.Frame._pad, and plotting.FrameRatio._pad.

1356  def setLogy(self, log):
1357  self._pad.SetLogy(log)
1358 

◆ setTitle()

def plotting.FrameRatio.setTitle (   self,
  title 
)

Definition at line 1385 of file plotting.py.

References plotting.Frame._frame, and plotting.FrameRatio._frame.

1385  def setTitle(self, title):
1386  self._frame.SetTitle(title)
1387 

◆ setXLabelSize()

def plotting.FrameRatio.setXLabelSize (   self,
  size 
)

Definition at line 1397 of file plotting.py.

References plotting.FrameRatio._frameRatio.

1397  def setXLabelSize(self, size):
1398  self._frameRatio.GetXaxis().SetLabelSize(size)
1399 

◆ setXTitle()

def plotting.FrameRatio.setXTitle (   self,
  title 
)

Definition at line 1388 of file plotting.py.

References plotting.FrameRatio._frameRatio.

1388  def setXTitle(self, title):
1389  self._frameRatio.GetXaxis().SetTitle(title)
1390 

◆ setXTitleOffset()

def plotting.FrameRatio.setXTitleOffset (   self,
  offset 
)

Definition at line 1394 of file plotting.py.

References plotting.FrameRatio._frameRatio.

1394  def setXTitleOffset(self, offset):
1395  self._frameRatio.GetXaxis().SetTitleOffset(offset)
1396 

◆ setXTitleSize()

def plotting.FrameRatio.setXTitleSize (   self,
  size 
)

Definition at line 1391 of file plotting.py.

References plotting.FrameRatio._frameRatio.

1391  def setXTitleSize(self, size):
1392  self._frameRatio.GetXaxis().SetTitleSize(size)
1393 

◆ setYTitle()

def plotting.FrameRatio.setYTitle (   self,
  title 
)

Definition at line 1400 of file plotting.py.

References plotting.Frame._frame, and plotting.FrameRatio._frame.

1400  def setYTitle(self, title):
1401  self._frame.GetYaxis().SetTitle(title)
1402 

◆ setYTitleOffset()

def plotting.FrameRatio.setYTitleOffset (   self,
  offset 
)

Definition at line 1410 of file plotting.py.

References plotting.Frame._frame, plotting.FrameRatio._frame, and plotting.FrameRatio._frameRatio.

1410  def setYTitleOffset(self, offset):
1411  self._frame.GetYaxis().SetTitleOffset(offset)
1412  self._frameRatio.GetYaxis().SetTitleOffset(offset)
1413 

◆ setYTitleRatio()

def plotting.FrameRatio.setYTitleRatio (   self,
  title 
)

Definition at line 1403 of file plotting.py.

References plotting.FrameRatio._frameRatio.

1403  def setYTitleRatio(self, title):
1404  self._frameRatio.GetYaxis().SetTitle(title)
1405 

◆ setYTitleSize()

def plotting.FrameRatio.setYTitleSize (   self,
  size 
)

Definition at line 1406 of file plotting.py.

References plotting.Frame._frame, plotting.FrameRatio._frame, and plotting.FrameRatio._frameRatio.

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

Member Data Documentation

◆ _coverPad

plotting.FrameRatio._coverPad
private

Definition at line 1425 of file plotting.py.

◆ _frame

plotting.FrameRatio._frame
private

◆ _frameRatio

plotting.FrameRatio._frameRatio
private

◆ _pad

plotting.FrameRatio._pad
private

◆ _padRatio

plotting.FrameRatio._padRatio
private

◆ _parentPad

plotting.FrameRatio._parentPad
private

Definition at line 1315 of file plotting.py.

Referenced by plotting.FrameRatio.redrawAxis().