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

Constructor & Destructor Documentation

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

Definition at line 1238 of file plotting.py.

1239  def __init__(self, pad, bounds, histos, ratioOrig, ratioFactor):
1240  self._pad = pad
1241  if ratioOrig:
1242  self._pad = pad.cd(1)
1243 
1244  # adjust margins because of not having the ratio, we want
1245  # the same bottom margin, so some algebra gives this
1246  (xlow, ylow, width, height) = (self._pad.GetXlowNDC(), self._pad.GetYlowNDC(), self._pad.GetWNDC(), self._pad.GetHNDC())
1247  xup = xlow+width
1248  yup = ylow+height
1249 
1250  bottomMargin = self._pad.GetBottomMargin()
1251  bottomMarginNew = ROOT.gStyle.GetPadBottomMargin()
1252 
1253  ylowNew = yup - (1-bottomMargin)/(1-bottomMarginNew) * (yup-ylow)
1254  topMarginNew = self._pad.GetTopMargin() * (yup-ylow)/(yup-ylowNew)
1255 
1256  self._pad.SetPad(xlow, ylowNew, xup, yup)
1257  self._pad.SetTopMargin(topMarginNew)
1258  self._pad.SetBottomMargin(bottomMarginNew)
1260  self._view = ROOT.TView.CreateView()
1261  self._view.SetRange(bounds[0], bounds[1], 0, bounds[2], bounds[3], 20) # 20 is from Harrison-Stetson, may need tuning?
1262  self._view.Top()
1263  self._view.ShowAxis()
1265  self._xtitleoffset = 1.8
1266  self._ytitleoffset = 2.3
1268  self._firstHisto = histos[0]

Member Function Documentation

def plotting.FrameTGraph2D.adjustMarginLeft (   self,
  adjust 
)

Definition at line 1281 of file plotting.py.

1282  def adjustMarginLeft(self, adjust):
1283  self._pad.SetLeftMargin(self._pad.GetLeftMargin()+adjust)
1284  self._pad.cd()
def plotting.FrameTGraph2D.adjustMarginRight (   self,
  adjust 
)

Definition at line 1285 of file plotting.py.

1286  def adjustMarginRight(self, adjust):
1287  self._pad.SetRightMargin(self._pad.GetRightMargin()+adjust)
1288  self._pad.cd()
def plotting.FrameTGraph2D.redrawAxis (   self)

Definition at line 1319 of file plotting.py.

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

1320  def redrawAxis(self):
1321  # Disabling and enabled the 3D rulers somehow magically moves the axes to their proper places
1322  ROOT.TAxis3D.ToggleRulers()
1323  ROOT.TAxis3D.ToggleRulers()
1324  axis = ROOT.TAxis3D.GetPadAxis()
1325  axis.SetLabelColor(ROOT.kBlack);
1326  axis.SetAxisColor(ROOT.kBlack);
1327 
1328  axis.GetXaxis().SetTitleOffset(self._xtitleoffset)
1329  axis.GetYaxis().SetTitleOffset(self._ytitleoffset)
1330 
1331  if hasattr(self, "_xtitle"):
1332  axis.GetXaxis().SetTitle(self._xtitle)
1333  if hasattr(self, "_xtitlesize"):
1334  axis.GetXaxis().SetTitleSize(self._xtitlesize)
1335  if hasattr(self, "_xlabelsize"):
1336  axis.GetXaxis().SetLabelSize(self._labelsize)
1337  if hasattr(self, "_ytitle"):
1338  axis.GetYaxis().SetTitle(self._ytitle)
1339  if hasattr(self, "_ytitlesize"):
1340  axis.GetYaxis().SetTitleSize(self._ytitlesize)
1341  if hasattr(self, "_ytitleoffset"):
1342  axis.GetYaxis().SetTitleOffset(self._ytitleoffset)
def plotting.FrameTGraph2D.setGridx (   self,
  grid 
)

Definition at line 1275 of file plotting.py.

1276  def setGridx(self, grid):
1277  pass
def plotting.FrameTGraph2D.setGridy (   self,
  grid 
)

Definition at line 1278 of file plotting.py.

1279  def setGridy(self, grid):
1280  pass
def plotting.FrameTGraph2D.setLogx (   self,
  log 
)

Definition at line 1269 of file plotting.py.

1270  def setLogx(self, log):
1271  pass
def plotting.FrameTGraph2D.setLogy (   self,
  log 
)

Definition at line 1272 of file plotting.py.

1273  def setLogy(self, log):
1274  pass
def plotting.FrameTGraph2D.setTitle (   self,
  title 
)

Definition at line 1289 of file plotting.py.

1290  def setTitle(self, title):
1291  pass
def plotting.FrameTGraph2D.setXLabelSize (   self,
  size 
)

Definition at line 1301 of file plotting.py.

1302  def setXLabelSize(self, size):
1303  self._xlabelsize = size
def plotting.FrameTGraph2D.setXTitle (   self,
  title 
)

Definition at line 1292 of file plotting.py.

1293  def setXTitle(self, title):
1294  self._xtitle = title
def plotting.FrameTGraph2D.setXTitleOffset (   self,
  size 
)

Definition at line 1298 of file plotting.py.

References plotting.FrameTGraph2D._xtitleoffset.

1299  def setXTitleOffset(self, size):
1300  self._xtitleoffset = size
def plotting.FrameTGraph2D.setXTitleSize (   self,
  size 
)

Definition at line 1295 of file plotting.py.

1296  def setXTitleSize(self, size):
1297  self._xtitlesize = size
def plotting.FrameTGraph2D.setYTitle (   self,
  title 
)

Definition at line 1304 of file plotting.py.

1305  def setYTitle(self, title):
1306  self._ytitle = title
def plotting.FrameTGraph2D.setYTitleOffset (   self,
  offset 
)

Definition at line 1310 of file plotting.py.

References plotting.FrameTGraph2D._ytitleoffset.

1311  def setYTitleOffset(self, offset):
1312  self._ytitleoffset = offset
def plotting.FrameTGraph2D.setYTitleSize (   self,
  size 
)

Definition at line 1307 of file plotting.py.

1308  def setYTitleSize(self, size):
1309  self._ytitlesize = size
def plotting.FrameTGraph2D.setZTitle (   self,
  title 
)

Definition at line 1313 of file plotting.py.

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

Definition at line 1316 of file plotting.py.

1317  def setZTitleOffset(self, offset):
1318  self._firstHisto.GetZaxis().SetTitleOffset(offset)

Member Data Documentation

plotting.FrameTGraph2D._firstHisto
private

Definition at line 1267 of file plotting.py.

plotting.FrameTGraph2D._pad
private

Definition at line 1239 of file plotting.py.

plotting.FrameTGraph2D._view
private

Definition at line 1259 of file plotting.py.

plotting.FrameTGraph2D._xlabelsize
private

Definition at line 1302 of file plotting.py.

plotting.FrameTGraph2D._xtitle
private

Definition at line 1293 of file plotting.py.

Referenced by plotting.FrameTGraph2D.redrawAxis().

plotting.FrameTGraph2D._xtitleoffset
private

Definition at line 1264 of file plotting.py.

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

plotting.FrameTGraph2D._xtitlesize
private

Definition at line 1296 of file plotting.py.

Referenced by plotting.FrameTGraph2D.redrawAxis().

plotting.FrameTGraph2D._ytitle
private

Definition at line 1305 of file plotting.py.

Referenced by plotting.FrameTGraph2D.redrawAxis().

plotting.FrameTGraph2D._ytitleoffset
private

Definition at line 1265 of file plotting.py.

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

plotting.FrameTGraph2D._ytitlesize
private

Definition at line 1308 of file plotting.py.

Referenced by plotting.FrameTGraph2D.redrawAxis().