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 1313 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 1315 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)
1352 

Member Function Documentation

◆ adjustMarginLeft()

def plotting.FrameRatio.adjustMarginLeft (   self,
  adjust 
)

Definition at line 1368 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("")
1376 

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

◆ adjustMarginRight()

def plotting.FrameRatio.adjustMarginRight (   self,
  adjust 
)

Definition at line 1377 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("")
1385 

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

◆ redrawAxis()

def plotting.FrameRatio.redrawAxis (   self)

Definition at line 1415 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
1432 

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

◆ setGridx()

def plotting.FrameRatio.setGridx (   self,
  grid 
)

Definition at line 1360 of file plotting.py.

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

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

◆ setGridy()

def plotting.FrameRatio.setGridy (   self,
  grid 
)

Definition at line 1364 of file plotting.py.

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

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

◆ setLogx()

def plotting.FrameRatio.setLogx (   self,
  log 
)

Definition at line 1353 of file plotting.py.

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

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

◆ setLogy()

def plotting.FrameRatio.setLogy (   self,
  log 
)

Definition at line 1357 of file plotting.py.

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

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

◆ setTitle()

def plotting.FrameRatio.setTitle (   self,
  title 
)

Definition at line 1386 of file plotting.py.

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

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

◆ setXLabelSize()

def plotting.FrameRatio.setXLabelSize (   self,
  size 
)

Definition at line 1398 of file plotting.py.

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

References plotting.FrameRatio._frameRatio.

◆ setXTitle()

def plotting.FrameRatio.setXTitle (   self,
  title 
)

Definition at line 1389 of file plotting.py.

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

References plotting.FrameRatio._frameRatio.

◆ setXTitleOffset()

def plotting.FrameRatio.setXTitleOffset (   self,
  offset 
)

Definition at line 1395 of file plotting.py.

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

References plotting.FrameRatio._frameRatio.

◆ setXTitleSize()

def plotting.FrameRatio.setXTitleSize (   self,
  size 
)

Definition at line 1392 of file plotting.py.

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

References plotting.FrameRatio._frameRatio.

◆ setYTitle()

def plotting.FrameRatio.setYTitle (   self,
  title 
)

Definition at line 1401 of file plotting.py.

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

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

◆ setYTitleOffset()

def plotting.FrameRatio.setYTitleOffset (   self,
  offset 
)

Definition at line 1411 of file plotting.py.

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

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

◆ setYTitleRatio()

def plotting.FrameRatio.setYTitleRatio (   self,
  title 
)

Definition at line 1404 of file plotting.py.

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

References plotting.FrameRatio._frameRatio.

◆ setYTitleSize()

def plotting.FrameRatio.setYTitleSize (   self,
  size 
)

Definition at line 1407 of file plotting.py.

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

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

Member Data Documentation

◆ _coverPad

plotting.FrameRatio._coverPad
private

Definition at line 1426 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 1316 of file plotting.py.

Referenced by plotting.FrameRatio.redrawAxis().

plotting._drawFrame
def _drawFrame(pad, bounds, zmax=None, xbinlabels=None, xbinlabelsize=None, xbinlabeloption=None, ybinlabels=None, suffix="")
Definition: plotting.py:1188
createfilelist.int
int
Definition: createfilelist.py:10
hgcalPlots.adjustMarginRight
adjustMarginRight
Definition: hgcalPlots.py:1163
trackingPlots.adjustMarginLeft
adjustMarginLeft
Definition: trackingPlots.py:227
hippyaddtobaddatafiles.cd
def cd(newdir)
Definition: hippyaddtobaddatafiles.py:40