test
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 662 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 664 of file plotting.py.

665  def __init__(self, pad, bounds, ratioBounds, ratioFactor, nrows, xbinlabels=None, xbinlabelsize=None, xbinlabeloption=None):
666  self._parentPad = pad
667  self._pad = pad.cd(1)
668  if xbinlabels is not None:
669  self._frame = _drawFrame(self._pad, bounds, [""]*len(xbinlabels))
670  else:
671  self._frame = _drawFrame(self._pad, bounds)
672  self._padRatio = pad.cd(2)
673  self._frameRatio = _drawFrame(self._padRatio, ratioBounds, xbinlabels, xbinlabelsize, xbinlabeloption)
674 
675  self._frame.GetXaxis().SetLabelSize(0)
676  self._frame.GetXaxis().SetTitleSize(0)
677 
678  yoffsetFactor = ratioFactor
679  divisionPoint = 1-1/ratioFactor
680  xoffsetFactor = 1/divisionPoint #* 0.6
681 
682  if nrows == 1:
683  xoffsetFactor *= 0.6
684  elif nrows == 2:
685  yoffsetFactor *= 2
686  xoffsetFactor *= 1.5
687  elif nrows == 3:
688  yoffsetFactor *= 4
689  xoffsetFactor *= 2.3
690  elif nrows >= 4:
691  yoffsetFactor *= 5
692  xoffsetFactor *= 3
693 
694  self._frame.GetYaxis().SetTitleOffset(self._frameRatio.GetYaxis().GetTitleOffset()*yoffsetFactor)
695  self._frameRatio.GetYaxis().SetLabelSize(int(self._frameRatio.GetYaxis().GetLabelSize()*0.8))
696  self._frameRatio.GetYaxis().SetTitleOffset(self._frameRatio.GetYaxis().GetTitleOffset()*yoffsetFactor)
697  self._frameRatio.GetXaxis().SetTitleOffset(self._frameRatio.GetXaxis().GetTitleOffset()*xoffsetFactor)
698 
699  self._frameRatio.GetYaxis().SetNdivisions(4, 5, 0)
700 
701  self._frameRatio.GetYaxis().SetTitle("Ratio")
def _drawFrame
Definition: plotting.py:556

Member Function Documentation

def plotting.FrameRatio.adjustMarginLeft (   self,
  adjust 
)

Definition at line 717 of file plotting.py.

718  def adjustMarginLeft(self, adjust):
719  self._pad.SetLeftMargin(self._pad.GetLeftMargin()+adjust)
720  self._padRatio.SetLeftMargin(self._padRatio.GetLeftMargin()+adjust)
721  # Need to redraw frame after adjusting the margin
722  self._pad.cd()
723  self._frame.Draw("")
724  self._padRatio.cd()
725  self._frameRatio.Draw("")
def plotting.FrameRatio.adjustMarginRight (   self,
  adjust 
)

Definition at line 726 of file plotting.py.

727  def adjustMarginRight(self, adjust):
728  self._pad.SetRightMargin(self._pad.GetRightMargin()+adjust)
729  self._padRatio.SetRightMargin(self._padRatio.GetRightMargin()+adjust)
730  # Need to redraw frames after adjusting the margin
731  self._pad.cd()
732  self._frame.Draw("")
733  self._padRatio.cd()
734  self._frameRatio.Draw("")
def plotting.FrameRatio.redrawAxis (   self)

Definition at line 764 of file plotting.py.

765  def redrawAxis(self):
766  self._padRatio.RedrawAxis()
767  self._pad.RedrawAxis()
768 
769  self._parentPad.cd()
770 
771  # pad to hide the lowest y axis label of the main pad
772  xmin=0.065
773  ymin=0.285
774  xmax=0.128
775  ymax=0.33
776  self._coverPad = ROOT.TPad("coverpad", "coverpad", xmin, ymin, xmax, ymax)
777  self._coverPad.SetBorderMode(0)
778  self._coverPad.Draw()
779 
780  self._pad.cd()
781  self._pad.Pop() # Move the first pad on top
def plotting.FrameRatio.setGridx (   self,
  grid 
)

Definition at line 709 of file plotting.py.

710  def setGridx(self, grid):
711  self._pad.SetGridx(grid)
712  self._padRatio.SetGridx(grid)
def plotting.FrameRatio.setGridy (   self,
  grid 
)

Definition at line 713 of file plotting.py.

714  def setGridy(self, grid):
715  self._pad.SetGridy(grid)
716  self._padRatio.SetGridy(grid)
def plotting.FrameRatio.setLogx (   self,
  log 
)

Definition at line 702 of file plotting.py.

703  def setLogx(self, log):
704  self._pad.SetLogx(log)
705  self._padRatio.SetLogx(log)
def plotting.FrameRatio.setLogy (   self,
  log 
)

Definition at line 706 of file plotting.py.

707  def setLogy(self, log):
708  self._pad.SetLogy(log)
def plotting.FrameRatio.setTitle (   self,
  title 
)

Definition at line 735 of file plotting.py.

736  def setTitle(self, title):
737  self._frame.SetTitle(title)
def plotting.FrameRatio.setXLabelSize (   self,
  size 
)

Definition at line 747 of file plotting.py.

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

Definition at line 738 of file plotting.py.

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

Definition at line 741 of file plotting.py.

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

Definition at line 750 of file plotting.py.

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

Definition at line 744 of file plotting.py.

Referenced by plotting.FrameRatio.setYTitleOffset().

745  def setYTitleOffset(self, offset):
746  self._frameRatio.GetXaxis().SetTitleOffset(offset)
def plotting.FrameRatio.setYTitleOffset (   self,
  offset 
)

Definition at line 760 of file plotting.py.

References plotting.FrameRatio.setYTitleOffset().

761  def setYTitleOffset(self, offset):
762  self._frame.GetYaxis().SetTitleOffset(offset)
763  self._frameRatio.GetYaxis().SetTitleOffset(offset)
def plotting.FrameRatio.setYTitleRatio (   self,
  title 
)

Definition at line 753 of file plotting.py.

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

Definition at line 756 of file plotting.py.

757  def setYTitleSize(self, size):
758  self._frame.GetYaxis().SetTitleSize(size)
759  self._frameRatio.GetYaxis().SetTitleSize(size)

Member Data Documentation

plotting.FrameRatio._coverPad
private

Definition at line 775 of file plotting.py.

plotting.FrameRatio._frame
private

Definition at line 668 of file plotting.py.

plotting.FrameRatio._frameRatio
private

Definition at line 672 of file plotting.py.

plotting.FrameRatio._pad
private

Definition at line 666 of file plotting.py.

plotting.FrameRatio._padRatio
private

Definition at line 671 of file plotting.py.

plotting.FrameRatio._parentPad
private

Definition at line 665 of file plotting.py.