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

Constructor & Destructor Documentation

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

Definition at line 1246 of file plotting.py.

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

Member Function Documentation

def plotting.FrameTGraph2D.adjustMarginLeft (   self,
  adjust 
)

Definition at line 1289 of file plotting.py.

1289  def adjustMarginLeft(self, adjust):
1290  self._pad.SetLeftMargin(self._pad.GetLeftMargin()+adjust)
1291  self._pad.cd()
1292 
def adjustMarginLeft(self, adjust)
Definition: plotting.py:1289
def plotting.FrameTGraph2D.adjustMarginRight (   self,
  adjust 
)

Definition at line 1293 of file plotting.py.

1293  def adjustMarginRight(self, adjust):
1294  self._pad.SetRightMargin(self._pad.GetRightMargin()+adjust)
1295  self._pad.cd()
1296 
def adjustMarginRight(self, adjust)
Definition: plotting.py:1293
def plotting.FrameTGraph2D.redrawAxis (   self)

Definition at line 1327 of file plotting.py.

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

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

Definition at line 1283 of file plotting.py.

1283  def setGridx(self, grid):
1284  pass
1285 
def setGridx(self, grid)
Definition: plotting.py:1283
def plotting.FrameTGraph2D.setGridy (   self,
  grid 
)

Definition at line 1286 of file plotting.py.

1286  def setGridy(self, grid):
1287  pass
1288 
def setGridy(self, grid)
Definition: plotting.py:1286
def plotting.FrameTGraph2D.setLogx (   self,
  log 
)

Definition at line 1277 of file plotting.py.

1277  def setLogx(self, log):
1278  pass
1279 
def setLogx(self, log)
Definition: plotting.py:1277
def plotting.FrameTGraph2D.setLogy (   self,
  log 
)

Definition at line 1280 of file plotting.py.

1280  def setLogy(self, log):
1281  pass
1282 
def setLogy(self, log)
Definition: plotting.py:1280
def plotting.FrameTGraph2D.setTitle (   self,
  title 
)

Definition at line 1297 of file plotting.py.

1297  def setTitle(self, title):
1298  pass
1299 
def setTitle(self, title)
Definition: plotting.py:1297
def plotting.FrameTGraph2D.setXLabelSize (   self,
  size 
)

Definition at line 1309 of file plotting.py.

1309  def setXLabelSize(self, size):
1310  self._xlabelsize = size
1311 
def setXLabelSize(self, size)
Definition: plotting.py:1309
def plotting.FrameTGraph2D.setXTitle (   self,
  title 
)

Definition at line 1300 of file plotting.py.

1300  def setXTitle(self, title):
1301  self._xtitle = title
1302 
def setXTitle(self, title)
Definition: plotting.py:1300
def plotting.FrameTGraph2D.setXTitleOffset (   self,
  size 
)

Definition at line 1306 of file plotting.py.

References plotting.FrameTGraph2D._xtitleoffset.

1306  def setXTitleOffset(self, size):
1307  self._xtitleoffset = size
1308 
def setXTitleOffset(self, size)
Definition: plotting.py:1306
def plotting.FrameTGraph2D.setXTitleSize (   self,
  size 
)

Definition at line 1303 of file plotting.py.

1303  def setXTitleSize(self, size):
1304  self._xtitlesize = size
1305 
def setXTitleSize(self, size)
Definition: plotting.py:1303
def plotting.FrameTGraph2D.setYTitle (   self,
  title 
)

Definition at line 1312 of file plotting.py.

1312  def setYTitle(self, title):
1313  self._ytitle = title
1314 
def setYTitle(self, title)
Definition: plotting.py:1312
def plotting.FrameTGraph2D.setYTitleOffset (   self,
  offset 
)

Definition at line 1318 of file plotting.py.

References plotting.FrameTGraph2D._ytitleoffset.

1318  def setYTitleOffset(self, offset):
1319  self._ytitleoffset = offset
1320 
def setYTitleOffset(self, offset)
Definition: plotting.py:1318
def plotting.FrameTGraph2D.setYTitleSize (   self,
  size 
)

Definition at line 1315 of file plotting.py.

1315  def setYTitleSize(self, size):
1316  self._ytitlesize = size
1317 
def setYTitleSize(self, size)
Definition: plotting.py:1315
def plotting.FrameTGraph2D.setZTitle (   self,
  title 
)

Definition at line 1321 of file plotting.py.

1321  def setZTitle(self, title):
1322  self._firstHisto.GetZaxis().SetTitle(title)
1323 
def setZTitle(self, title)
Definition: plotting.py:1321
def plotting.FrameTGraph2D.setZTitleOffset (   self,
  offset 
)

Definition at line 1324 of file plotting.py.

1324  def setZTitleOffset(self, offset):
1325  self._firstHisto.GetZaxis().SetTitleOffset(offset)
1326 
def setZTitleOffset(self, offset)
Definition: plotting.py:1324

Member Data Documentation

plotting.FrameTGraph2D._firstHisto
private

Definition at line 1275 of file plotting.py.

plotting.FrameTGraph2D._pad
private

Definition at line 1247 of file plotting.py.

plotting.FrameTGraph2D._view
private

Definition at line 1267 of file plotting.py.

plotting.FrameTGraph2D._xlabelsize
private

Definition at line 1310 of file plotting.py.

plotting.FrameTGraph2D._xtitle
private

Definition at line 1301 of file plotting.py.

Referenced by plotting.FrameTGraph2D.redrawAxis().

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

Definition at line 1304 of file plotting.py.

Referenced by plotting.FrameTGraph2D.redrawAxis().

plotting.FrameTGraph2D._ytitle
private

Definition at line 1313 of file plotting.py.

Referenced by plotting.FrameTGraph2D.redrawAxis().

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

Definition at line 1316 of file plotting.py.

Referenced by plotting.FrameTGraph2D.redrawAxis().