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.FrameTGraph2D 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 setYTitleSize
 
def setZTitle
 
def setZTitleOffset
 

Private Attributes

 _firstHisto
 
 _pad
 
 _view
 
 _xlabelsize
 
 _xtitle
 
 _xtitleoffset
 
 _xtitlesize
 
 _ytitle
 
 _ytitleoffset
 
 _ytitlesize
 

Detailed Description

Class for creating and managing a frame for a plot from TGraph2D

Definition at line 663 of file plotting.py.

Constructor & Destructor Documentation

def plotting.FrameTGraph2D.__init__ (   self,
  pad,
  bounds,
  histos,
  ratioOrig,
  ratioFactor 
)

Definition at line 665 of file plotting.py.

666  def __init__(self, pad, bounds, histos, ratioOrig, ratioFactor):
667  self._pad = pad
668  if ratioOrig:
669  self._pad = pad.cd(1)
670 
671  # adjust margins because of not having the ratio, we want
672  # the same bottom margin, so some algebra gives this
673  (xlow, ylow, width, height) = (self._pad.GetXlowNDC(), self._pad.GetYlowNDC(), self._pad.GetWNDC(), self._pad.GetHNDC())
674  xup = xlow+width
675  yup = ylow+height
676 
677  bottomMargin = self._pad.GetBottomMargin()
678  bottomMarginNew = ROOT.gStyle.GetPadBottomMargin()
679 
680  ylowNew = yup - (1-bottomMargin)/(1-bottomMarginNew) * (yup-ylow)
681  topMarginNew = self._pad.GetTopMargin() * (yup-ylow)/(yup-ylowNew)
682 
683  self._pad.SetPad(xlow, ylowNew, xup, yup)
684  self._pad.SetTopMargin(topMarginNew)
685  self._pad.SetBottomMargin(bottomMarginNew)
687  self._view = ROOT.TView.CreateView()
688  self._view.SetRange(bounds[0], bounds[1], 0, bounds[2], bounds[3], 20) # 20 is from Harrison-Stetson, may need tuning?
689  self._view.Top()
690  self._view.ShowAxis()
692  self._xtitleoffset = 1.8
693  self._ytitleoffset = 2.3
695  self._firstHisto = histos[0]

Member Function Documentation

def plotting.FrameTGraph2D.adjustMarginLeft (   self,
  adjust 
)

Definition at line 708 of file plotting.py.

709  def adjustMarginLeft(self, adjust):
710  self._pad.SetLeftMargin(self._pad.GetLeftMargin()+adjust)
711  self._pad.cd()
def plotting.FrameTGraph2D.adjustMarginRight (   self,
  adjust 
)

Definition at line 712 of file plotting.py.

713  def adjustMarginRight(self, adjust):
714  self._pad.SetRightMargin(self._pad.GetRightMargin()+adjust)
715  self._pad.cd()
def plotting.FrameTGraph2D.redrawAxis (   self)

Definition at line 746 of file plotting.py.

References plotting.FrameTGraph2D._xtitle, plotting.FrameTGraph2D._xtitleoffset, plotting.FrameTGraph2D._xtitlesize, plotting.FrameTGraph2D._ytitle, plotting.FrameTGraph2D._ytitleoffset, and plotting.FrameTGraph2D._ytitlesize.

747  def redrawAxis(self):
748  # Disabling and enabled the 3D rulers somehow magically moves the axes to their proper places
749  ROOT.TAxis3D.ToggleRulers()
750  ROOT.TAxis3D.ToggleRulers()
751  axis = ROOT.TAxis3D.GetPadAxis()
752  axis.SetLabelColor(ROOT.kBlack);
753  axis.SetAxisColor(ROOT.kBlack);
754 
755  axis.GetXaxis().SetTitleOffset(self._xtitleoffset)
756  axis.GetYaxis().SetTitleOffset(self._ytitleoffset)
757 
758  if hasattr(self, "_xtitle"):
759  axis.GetXaxis().SetTitle(self._xtitle)
760  if hasattr(self, "_xtitlesize"):
761  axis.GetXaxis().SetTitleSize(self._xtitlesize)
762  if hasattr(self, "_xlabelsize"):
763  axis.GetXaxis().SetLabelSize(self._labelsize)
764  if hasattr(self, "_ytitle"):
765  axis.GetYaxis().SetTitle(self._ytitle)
766  if hasattr(self, "_ytitlesize"):
767  axis.GetYaxis().SetTitleSize(self._ytitlesize)
768  if hasattr(self, "_ytitleoffset"):
769  axis.GetYaxis().SetTitleOffset(self._ytitleoffset)
def plotting.FrameTGraph2D.setGridx (   self,
  grid 
)

Definition at line 702 of file plotting.py.

703  def setGridx(self, grid):
704  pass
def plotting.FrameTGraph2D.setGridy (   self,
  grid 
)

Definition at line 705 of file plotting.py.

706  def setGridy(self, grid):
707  pass
def plotting.FrameTGraph2D.setLogx (   self,
  log 
)

Definition at line 696 of file plotting.py.

697  def setLogx(self, log):
698  pass
def plotting.FrameTGraph2D.setLogy (   self,
  log 
)

Definition at line 699 of file plotting.py.

700  def setLogy(self, log):
701  pass
def plotting.FrameTGraph2D.setTitle (   self,
  title 
)

Definition at line 716 of file plotting.py.

717  def setTitle(self, title):
718  pass
def plotting.FrameTGraph2D.setXLabelSize (   self,
  size 
)

Definition at line 728 of file plotting.py.

729  def setXLabelSize(self, size):
730  self._xlabelsize = size
def plotting.FrameTGraph2D.setXTitle (   self,
  title 
)

Definition at line 719 of file plotting.py.

720  def setXTitle(self, title):
721  self._xtitle = title
def plotting.FrameTGraph2D.setXTitleOffset (   self,
  size 
)

Definition at line 725 of file plotting.py.

References plotting.FrameTGraph2D._xtitleoffset.

726  def setXTitleOffset(self, size):
727  self._xtitleoffset = size
def plotting.FrameTGraph2D.setXTitleSize (   self,
  size 
)

Definition at line 722 of file plotting.py.

723  def setXTitleSize(self, size):
724  self._xtitlesize = size
def plotting.FrameTGraph2D.setYTitle (   self,
  title 
)

Definition at line 731 of file plotting.py.

732  def setYTitle(self, title):
733  self._ytitle = title
def plotting.FrameTGraph2D.setYTitleOffset (   self,
  offset 
)

Definition at line 737 of file plotting.py.

References plotting.FrameTGraph2D._ytitleoffset.

738  def setYTitleOffset(self, offset):
739  self._ytitleoffset = offset
def plotting.FrameTGraph2D.setYTitleSize (   self,
  size 
)

Definition at line 734 of file plotting.py.

735  def setYTitleSize(self, size):
736  self._ytitlesize = size
def plotting.FrameTGraph2D.setZTitle (   self,
  title 
)

Definition at line 740 of file plotting.py.

741  def setZTitle(self, title):
742  self._firstHisto.GetZaxis().SetTitle(title)
def plotting.FrameTGraph2D.setZTitleOffset (   self,
  offset 
)

Definition at line 743 of file plotting.py.

744  def setZTitleOffset(self, offset):
745  self._firstHisto.GetZaxis().SetTitleOffset(offset)

Member Data Documentation

plotting.FrameTGraph2D._firstHisto
private

Definition at line 694 of file plotting.py.

plotting.FrameTGraph2D._pad
private

Definition at line 666 of file plotting.py.

plotting.FrameTGraph2D._view
private

Definition at line 686 of file plotting.py.

plotting.FrameTGraph2D._xlabelsize
private

Definition at line 729 of file plotting.py.

Referenced by plotting.Plot.draw().

plotting.FrameTGraph2D._xtitle
private

Definition at line 720 of file plotting.py.

Referenced by plotting.Plot.draw(), and plotting.FrameTGraph2D.redrawAxis().

plotting.FrameTGraph2D._xtitleoffset
private

Definition at line 691 of file plotting.py.

Referenced by plotting.Plot.draw(), plotting.FrameTGraph2D.redrawAxis(), and plotting.FrameTGraph2D.setXTitleOffset().

plotting.FrameTGraph2D._xtitlesize
private

Definition at line 723 of file plotting.py.

Referenced by plotting.Plot.draw(), and plotting.FrameTGraph2D.redrawAxis().

plotting.FrameTGraph2D._ytitle
private

Definition at line 732 of file plotting.py.

Referenced by plotting.Plot.draw(), and plotting.FrameTGraph2D.redrawAxis().

plotting.FrameTGraph2D._ytitleoffset
private

Definition at line 692 of file plotting.py.

Referenced by plotting.Plot.draw(), plotting.FrameTGraph2D.redrawAxis(), and plotting.FrameTGraph2D.setYTitleOffset().

plotting.FrameTGraph2D._ytitlesize
private

Definition at line 735 of file plotting.py.

Referenced by plotting.Plot.draw(), and plotting.FrameTGraph2D.redrawAxis().