CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 setXTitleSize
 
def setYTitle
 
def setYTitleOffset
 
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 543 of file plotting.py.

Constructor & Destructor Documentation

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

Definition at line 545 of file plotting.py.

546  def __init__(self, pad, bounds, ratioBounds, ratioFactor, nrows, xbinlabels=None, xbinlabelsize=None, xbinlabeloption=None):
547  self._parentPad = pad
548  self._pad = pad.cd(1)
549  if xbinlabels is not None:
550  self._frame = _drawFrame(self._pad, bounds, [""]*len(xbinlabels))
551  else:
552  self._frame = _drawFrame(self._pad, bounds)
553  self._padRatio = pad.cd(2)
554  self._frameRatio = _drawFrame(self._padRatio, ratioBounds, xbinlabels, xbinlabelsize, xbinlabeloption)
555 
556  self._frame.GetXaxis().SetLabelSize(0)
557  self._frame.GetXaxis().SetTitleSize(0)
558 
559  yoffsetFactor = ratioFactor
560  divisionPoint = 1-1/ratioFactor
561  xoffsetFactor = 1/divisionPoint #* 0.6
562 
563  if nrows == 1:
564  xoffsetFactor *= 0.6
565  elif nrows == 2:
566  yoffsetFactor *= 2
567  xoffsetFactor *= 1.5
568  elif nrows == 3:
569  yoffsetFactor *= 4
570  xoffsetFactor *= 2.3
571  elif nrows >= 4:
572  yoffsetFactor *= 5
573  xoffsetFactor *= 3
574 
575  self._frame.GetYaxis().SetTitleOffset(self._frameRatio.GetYaxis().GetTitleOffset()*yoffsetFactor)
576  self._frameRatio.GetYaxis().SetLabelSize(int(self._frameRatio.GetYaxis().GetLabelSize()*0.8))
577  self._frameRatio.GetYaxis().SetTitleOffset(self._frameRatio.GetYaxis().GetTitleOffset()*yoffsetFactor)
578  self._frameRatio.GetXaxis().SetTitleOffset(self._frameRatio.GetXaxis().GetTitleOffset()*xoffsetFactor)
579 
580  self._frameRatio.GetYaxis().SetNdivisions(4, 5, 0)
581 
582  self._frameRatio.GetYaxis().SetTitle("Ratio")
def _drawFrame
Definition: plotting.py:437

Member Function Documentation

def plotting.FrameRatio.adjustMarginLeft (   self,
  adjust 
)

Definition at line 598 of file plotting.py.

599  def adjustMarginLeft(self, adjust):
600  self._pad.SetLeftMargin(self._pad.GetLeftMargin()+adjust)
601  self._padRatio.SetLeftMargin(self._padRatio.GetLeftMargin()+adjust)
602  # Need to redraw frame after adjusting the margin
603  self._pad.cd()
604  self._frame.Draw("")
605  self._padRatio.cd()
606  self._frameRatio.Draw("")
def plotting.FrameRatio.adjustMarginRight (   self,
  adjust 
)

Definition at line 607 of file plotting.py.

608  def adjustMarginRight(self, adjust):
609  self._pad.SetRightMargin(self._pad.GetRightMargin()+adjust)
610  self._padRatio.SetRightMargin(self._padRatio.GetRightMargin()+adjust)
611  # Need to redraw frames after adjusting the margin
612  self._pad.cd()
613  self._frame.Draw("")
614  self._padRatio.cd()
615  self._frameRatio.Draw("")
def plotting.FrameRatio.redrawAxis (   self)

Definition at line 645 of file plotting.py.

646  def redrawAxis(self):
647  self._padRatio.RedrawAxis()
648  self._pad.RedrawAxis()
649 
650  self._parentPad.cd()
651 
652  # pad to hide the lowest y axis label of the main pad
653  xmin=0.065
654  ymin=0.285
655  xmax=0.128
656  ymax=0.33
657  self._coverPad = ROOT.TPad("coverpad", "coverpad", xmin, ymin, xmax, ymax)
658  self._coverPad.SetBorderMode(0)
659  self._coverPad.Draw()
660 
661  self._pad.cd()
662  self._pad.Pop() # Move the first pad on top
def plotting.FrameRatio.setGridx (   self,
  grid 
)

Definition at line 590 of file plotting.py.

591  def setGridx(self, grid):
592  self._pad.SetGridx(grid)
593  self._padRatio.SetGridx(grid)
def plotting.FrameRatio.setGridy (   self,
  grid 
)

Definition at line 594 of file plotting.py.

595  def setGridy(self, grid):
596  self._pad.SetGridy(grid)
597  self._padRatio.SetGridy(grid)
def plotting.FrameRatio.setLogx (   self,
  log 
)

Definition at line 583 of file plotting.py.

584  def setLogx(self, log):
585  self._pad.SetLogx(log)
586  self._padRatio.SetLogx(log)
def plotting.FrameRatio.setLogy (   self,
  log 
)

Definition at line 587 of file plotting.py.

588  def setLogy(self, log):
589  self._pad.SetLogy(log)
def plotting.FrameRatio.setTitle (   self,
  title 
)

Definition at line 616 of file plotting.py.

617  def setTitle(self, title):
618  self._frame.SetTitle(title)
def plotting.FrameRatio.setXLabelSize (   self,
  size 
)

Definition at line 628 of file plotting.py.

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

Definition at line 619 of file plotting.py.

620  def setXTitle(self, title):
621  self._frameRatio.GetXaxis().SetTitle(title)
def plotting.FrameRatio.setXTitleSize (   self,
  size 
)

Definition at line 622 of file plotting.py.

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

Definition at line 631 of file plotting.py.

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

Definition at line 625 of file plotting.py.

Referenced by plotting.FrameRatio.setYTitleOffset().

626  def setYTitleOffset(self, offset):
627  self._frameRatio.GetXaxis().SetTitleOffset(offset)
def plotting.FrameRatio.setYTitleOffset (   self,
  offset 
)

Definition at line 641 of file plotting.py.

References plotting.FrameRatio.setYTitleOffset().

642  def setYTitleOffset(self, offset):
643  self._frame.GetYaxis().SetTitleOffset(offset)
644  self._frameRatio.GetYaxis().SetTitleOffset(offset)
def plotting.FrameRatio.setYTitleRatio (   self,
  title 
)

Definition at line 634 of file plotting.py.

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

Definition at line 637 of file plotting.py.

638  def setYTitleSize(self, size):
639  self._frame.GetYaxis().SetTitleSize(size)
640  self._frameRatio.GetYaxis().SetTitleSize(size)

Member Data Documentation

plotting.FrameRatio._coverPad
private

Definition at line 656 of file plotting.py.

plotting.FrameRatio._frame
private

Definition at line 549 of file plotting.py.

plotting.FrameRatio._frameRatio
private

Definition at line 553 of file plotting.py.

plotting.FrameRatio._pad
private

Definition at line 547 of file plotting.py.

plotting.FrameRatio._padRatio
private

Definition at line 552 of file plotting.py.

plotting.FrameRatio._parentPad
private

Definition at line 546 of file plotting.py.