CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
plotting.FrameTGraph2D Class Reference

Public Member Functions

def __init__ (self, pad, bounds, histos, ratioOrig, ratioFactor)
 
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, size)
 
def setXTitleSize (self, size)
 
def setYTitle (self, title)
 
def setYTitleOffset (self, offset)
 
def setYTitleSize (self, size)
 
def setZTitle (self, title)
 
def setZTitleOffset (self, offset)
 

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

Constructor & Destructor Documentation

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

Definition at line 1428 of file plotting.py.

1428  def __init__(self, pad, bounds, histos, ratioOrig, ratioFactor):
1429  self._pad = pad
1430  if ratioOrig:
1431  self._pad = pad.cd(1)
1432 
1433  # adjust margins because of not having the ratio, we want
1434  # the same bottom margin, so some algebra gives this
1435  (xlow, ylow, width, height) = (self._pad.GetXlowNDC(), self._pad.GetYlowNDC(), self._pad.GetWNDC(), self._pad.GetHNDC())
1436  xup = xlow+width
1437  yup = ylow+height
1438 
1439  bottomMargin = self._pad.GetBottomMargin()
1440  bottomMarginNew = ROOT.gStyle.GetPadBottomMargin()
1441 
1442  ylowNew = yup - (1-bottomMargin)/(1-bottomMarginNew) * (yup-ylow)
1443  topMarginNew = self._pad.GetTopMargin() * (yup-ylow)/(yup-ylowNew)
1444 
1445  self._pad.SetPad(xlow, ylowNew, xup, yup)
1446  self._pad.SetTopMargin(topMarginNew)
1447  self._pad.SetBottomMargin(bottomMarginNew)
1448 
1449  self._view = ROOT.TView.CreateView()
1450  self._view.SetRange(bounds[0], bounds[1], 0, bounds[2], bounds[3], 20) # 20 is from Harrison-Stetson, may need tuning?
1451  self._view.Top()
1452  self._view.ShowAxis()
1453 
1454  self._xtitleoffset = 1.8
1455  self._ytitleoffset = 2.3
1456 
1457  self._firstHisto = histos[0]
1458 
def __init__(self, pad, bounds, histos, ratioOrig, ratioFactor)
Definition: plotting.py:1428

Member Function Documentation

def plotting.FrameTGraph2D.adjustMarginLeft (   self,
  adjust 
)

Definition at line 1471 of file plotting.py.

1471  def adjustMarginLeft(self, adjust):
1472  self._pad.SetLeftMargin(self._pad.GetLeftMargin()+adjust)
1473  self._pad.cd()
1474 
def adjustMarginLeft(self, adjust)
Definition: plotting.py:1471
def plotting.FrameTGraph2D.adjustMarginRight (   self,
  adjust 
)

Definition at line 1475 of file plotting.py.

1475  def adjustMarginRight(self, adjust):
1476  self._pad.SetRightMargin(self._pad.GetRightMargin()+adjust)
1477  self._pad.cd()
1478 
def adjustMarginRight(self, adjust)
Definition: plotting.py:1475
def plotting.FrameTGraph2D.redrawAxis (   self)

Definition at line 1509 of file plotting.py.

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

1509  def redrawAxis(self):
1510  # Disabling and enabled the 3D rulers somehow magically moves the axes to their proper places
1511  ROOT.TAxis3D.ToggleRulers()
1512  ROOT.TAxis3D.ToggleRulers()
1513  axis = ROOT.TAxis3D.GetPadAxis()
1514  axis.SetLabelColor(ROOT.kBlack);
1515  axis.SetAxisColor(ROOT.kBlack);
1516 
1517  axis.GetXaxis().SetTitleOffset(self._xtitleoffset)
1518  axis.GetYaxis().SetTitleOffset(self._ytitleoffset)
1519 
1520  if hasattr(self, "_xtitle"):
1521  axis.GetXaxis().SetTitle(self._xtitle)
1522  if hasattr(self, "_xtitlesize"):
1523  axis.GetXaxis().SetTitleSize(self._xtitlesize)
1524  if hasattr(self, "_xlabelsize"):
1525  axis.GetXaxis().SetLabelSize(self._labelsize)
1526  if hasattr(self, "_ytitle"):
1527  axis.GetYaxis().SetTitle(self._ytitle)
1528  if hasattr(self, "_ytitlesize"):
1529  axis.GetYaxis().SetTitleSize(self._ytitlesize)
1530  if hasattr(self, "_ytitleoffset"):
1531  axis.GetYaxis().SetTitleOffset(self._ytitleoffset)
1532 
def plotting.FrameTGraph2D.setGridx (   self,
  grid 
)

Definition at line 1465 of file plotting.py.

1465  def setGridx(self, grid):
1466  pass
1467 
def setGridx(self, grid)
Definition: plotting.py:1465
def plotting.FrameTGraph2D.setGridy (   self,
  grid 
)

Definition at line 1468 of file plotting.py.

1468  def setGridy(self, grid):
1469  pass
1470 
def setGridy(self, grid)
Definition: plotting.py:1468
def plotting.FrameTGraph2D.setLogx (   self,
  log 
)

Definition at line 1459 of file plotting.py.

1459  def setLogx(self, log):
1460  pass
1461 
def setLogx(self, log)
Definition: plotting.py:1459
def plotting.FrameTGraph2D.setLogy (   self,
  log 
)

Definition at line 1462 of file plotting.py.

1462  def setLogy(self, log):
1463  pass
1464 
def setLogy(self, log)
Definition: plotting.py:1462
def plotting.FrameTGraph2D.setTitle (   self,
  title 
)

Definition at line 1479 of file plotting.py.

1479  def setTitle(self, title):
1480  pass
1481 
def setTitle(self, title)
Definition: plotting.py:1479
def plotting.FrameTGraph2D.setXLabelSize (   self,
  size 
)

Definition at line 1491 of file plotting.py.

1491  def setXLabelSize(self, size):
1492  self._xlabelsize = size
1493 
def setXLabelSize(self, size)
Definition: plotting.py:1491
def plotting.FrameTGraph2D.setXTitle (   self,
  title 
)

Definition at line 1482 of file plotting.py.

1482  def setXTitle(self, title):
1483  self._xtitle = title
1484 
def setXTitle(self, title)
Definition: plotting.py:1482
def plotting.FrameTGraph2D.setXTitleOffset (   self,
  size 
)

Definition at line 1488 of file plotting.py.

References plotting.FrameTGraph2D._xtitleoffset.

1488  def setXTitleOffset(self, size):
1489  self._xtitleoffset = size
1490 
def setXTitleOffset(self, size)
Definition: plotting.py:1488
def plotting.FrameTGraph2D.setXTitleSize (   self,
  size 
)

Definition at line 1485 of file plotting.py.

1485  def setXTitleSize(self, size):
1486  self._xtitlesize = size
1487 
def setXTitleSize(self, size)
Definition: plotting.py:1485
def plotting.FrameTGraph2D.setYTitle (   self,
  title 
)

Definition at line 1494 of file plotting.py.

1494  def setYTitle(self, title):
1495  self._ytitle = title
1496 
def setYTitle(self, title)
Definition: plotting.py:1494
def plotting.FrameTGraph2D.setYTitleOffset (   self,
  offset 
)

Definition at line 1500 of file plotting.py.

References plotting.FrameTGraph2D._ytitleoffset.

1500  def setYTitleOffset(self, offset):
1501  self._ytitleoffset = offset
1502 
def setYTitleOffset(self, offset)
Definition: plotting.py:1500
def plotting.FrameTGraph2D.setYTitleSize (   self,
  size 
)

Definition at line 1497 of file plotting.py.

1497  def setYTitleSize(self, size):
1498  self._ytitlesize = size
1499 
def setYTitleSize(self, size)
Definition: plotting.py:1497
def plotting.FrameTGraph2D.setZTitle (   self,
  title 
)

Definition at line 1503 of file plotting.py.

1503  def setZTitle(self, title):
1504  self._firstHisto.GetZaxis().SetTitle(title)
1505 
def setZTitle(self, title)
Definition: plotting.py:1503
def plotting.FrameTGraph2D.setZTitleOffset (   self,
  offset 
)

Definition at line 1506 of file plotting.py.

1506  def setZTitleOffset(self, offset):
1507  self._firstHisto.GetZaxis().SetTitleOffset(offset)
1508 
def setZTitleOffset(self, offset)
Definition: plotting.py:1506

Member Data Documentation

plotting.FrameTGraph2D._firstHisto
private

Definition at line 1457 of file plotting.py.

plotting.FrameTGraph2D._pad
private

Definition at line 1429 of file plotting.py.

plotting.FrameTGraph2D._view
private

Definition at line 1449 of file plotting.py.

plotting.FrameTGraph2D._xlabelsize
private

Definition at line 1492 of file plotting.py.

plotting.FrameTGraph2D._xtitle
private

Definition at line 1483 of file plotting.py.

Referenced by plotting.FrameTGraph2D.redrawAxis().

plotting.FrameTGraph2D._xtitleoffset
private
plotting.FrameTGraph2D._xtitlesize
private

Definition at line 1486 of file plotting.py.

Referenced by plotting.FrameTGraph2D.redrawAxis().

plotting.FrameTGraph2D._ytitle
private

Definition at line 1495 of file plotting.py.

Referenced by plotting.FrameTGraph2D.redrawAxis().

plotting.FrameTGraph2D._ytitleoffset
private
plotting.FrameTGraph2D._ytitlesize
private

Definition at line 1498 of file plotting.py.

Referenced by plotting.FrameTGraph2D.redrawAxis().