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

Constructor & Destructor Documentation

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

Definition at line 1228 of file plotting.py.

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

Member Function Documentation

def plotting.FrameTGraph2D.adjustMarginLeft (   self,
  adjust 
)

Definition at line 1271 of file plotting.py.

1272  def adjustMarginLeft(self, adjust):
1273  self._pad.SetLeftMargin(self._pad.GetLeftMargin()+adjust)
1274  self._pad.cd()
def plotting.FrameTGraph2D.adjustMarginRight (   self,
  adjust 
)

Definition at line 1275 of file plotting.py.

1276  def adjustMarginRight(self, adjust):
1277  self._pad.SetRightMargin(self._pad.GetRightMargin()+adjust)
1278  self._pad.cd()
def plotting.FrameTGraph2D.redrawAxis (   self)

Definition at line 1309 of file plotting.py.

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

1310  def redrawAxis(self):
1311  # Disabling and enabled the 3D rulers somehow magically moves the axes to their proper places
1312  ROOT.TAxis3D.ToggleRulers()
1313  ROOT.TAxis3D.ToggleRulers()
1314  axis = ROOT.TAxis3D.GetPadAxis()
1315  axis.SetLabelColor(ROOT.kBlack);
1316  axis.SetAxisColor(ROOT.kBlack);
1317 
1318  axis.GetXaxis().SetTitleOffset(self._xtitleoffset)
1319  axis.GetYaxis().SetTitleOffset(self._ytitleoffset)
1320 
1321  if hasattr(self, "_xtitle"):
1322  axis.GetXaxis().SetTitle(self._xtitle)
1323  if hasattr(self, "_xtitlesize"):
1324  axis.GetXaxis().SetTitleSize(self._xtitlesize)
1325  if hasattr(self, "_xlabelsize"):
1326  axis.GetXaxis().SetLabelSize(self._labelsize)
1327  if hasattr(self, "_ytitle"):
1328  axis.GetYaxis().SetTitle(self._ytitle)
1329  if hasattr(self, "_ytitlesize"):
1330  axis.GetYaxis().SetTitleSize(self._ytitlesize)
1331  if hasattr(self, "_ytitleoffset"):
1332  axis.GetYaxis().SetTitleOffset(self._ytitleoffset)
def plotting.FrameTGraph2D.setGridx (   self,
  grid 
)

Definition at line 1265 of file plotting.py.

1266  def setGridx(self, grid):
1267  pass
def plotting.FrameTGraph2D.setGridy (   self,
  grid 
)

Definition at line 1268 of file plotting.py.

1269  def setGridy(self, grid):
1270  pass
def plotting.FrameTGraph2D.setLogx (   self,
  log 
)

Definition at line 1259 of file plotting.py.

1260  def setLogx(self, log):
1261  pass
def plotting.FrameTGraph2D.setLogy (   self,
  log 
)

Definition at line 1262 of file plotting.py.

1263  def setLogy(self, log):
1264  pass
def plotting.FrameTGraph2D.setTitle (   self,
  title 
)

Definition at line 1279 of file plotting.py.

1280  def setTitle(self, title):
1281  pass
def plotting.FrameTGraph2D.setXLabelSize (   self,
  size 
)

Definition at line 1291 of file plotting.py.

1292  def setXLabelSize(self, size):
1293  self._xlabelsize = size
def plotting.FrameTGraph2D.setXTitle (   self,
  title 
)

Definition at line 1282 of file plotting.py.

1283  def setXTitle(self, title):
1284  self._xtitle = title
def plotting.FrameTGraph2D.setXTitleOffset (   self,
  size 
)

Definition at line 1288 of file plotting.py.

References plotting.FrameTGraph2D._xtitleoffset.

1289  def setXTitleOffset(self, size):
1290  self._xtitleoffset = size
def plotting.FrameTGraph2D.setXTitleSize (   self,
  size 
)

Definition at line 1285 of file plotting.py.

1286  def setXTitleSize(self, size):
1287  self._xtitlesize = size
def plotting.FrameTGraph2D.setYTitle (   self,
  title 
)

Definition at line 1294 of file plotting.py.

1295  def setYTitle(self, title):
1296  self._ytitle = title
def plotting.FrameTGraph2D.setYTitleOffset (   self,
  offset 
)

Definition at line 1300 of file plotting.py.

References plotting.FrameTGraph2D._ytitleoffset.

1301  def setYTitleOffset(self, offset):
1302  self._ytitleoffset = offset
def plotting.FrameTGraph2D.setYTitleSize (   self,
  size 
)

Definition at line 1297 of file plotting.py.

1298  def setYTitleSize(self, size):
1299  self._ytitlesize = size
def plotting.FrameTGraph2D.setZTitle (   self,
  title 
)

Definition at line 1303 of file plotting.py.

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

Definition at line 1306 of file plotting.py.

1307  def setZTitleOffset(self, offset):
1308  self._firstHisto.GetZaxis().SetTitleOffset(offset)

Member Data Documentation

plotting.FrameTGraph2D._firstHisto
private

Definition at line 1257 of file plotting.py.

plotting.FrameTGraph2D._pad
private

Definition at line 1229 of file plotting.py.

plotting.FrameTGraph2D._view
private

Definition at line 1249 of file plotting.py.

plotting.FrameTGraph2D._xlabelsize
private

Definition at line 1292 of file plotting.py.

plotting.FrameTGraph2D._xtitle
private

Definition at line 1283 of file plotting.py.

Referenced by plotting.FrameTGraph2D.redrawAxis().

plotting.FrameTGraph2D._xtitleoffset
private

Definition at line 1254 of file plotting.py.

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

plotting.FrameTGraph2D._xtitlesize
private

Definition at line 1286 of file plotting.py.

Referenced by plotting.FrameTGraph2D.redrawAxis().

plotting.FrameTGraph2D._ytitle
private

Definition at line 1295 of file plotting.py.

Referenced by plotting.FrameTGraph2D.redrawAxis().

plotting.FrameTGraph2D._ytitleoffset
private

Definition at line 1255 of file plotting.py.

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

plotting.FrameTGraph2D._ytitlesize
private

Definition at line 1298 of file plotting.py.

Referenced by plotting.FrameTGraph2D.redrawAxis().