Plot

class Plot.Plot(name=None, **kwargs)[source]

Bases: MethodProxy.MethodProxy

Class for creating plots.

Stores ROOT objects like histograms and draws them in their specified Pad onto a Canvas.

__init__(name=None, **kwargs)[source]

Initialize a plot.

Create an instance of Plot with the specified name.

Parameters:
  • name (str) – name of the plot (default: random 8-digits HEX hash value)
  • **kwargsPlot properties
GetName()[source]

Return the name of the plot object.

Returntype:str
SetNPads(npads)[source]

Set the number of Pad s associated to the plot.

This will also determine the size and layout of the underlying Canvas.

Parameters:npads (int) – number of pads (default: 1)
GetNPads()[source]

Return the number of Pad s associated to the plot.

Returntype:int
Register(object, pad=0, **kwargs)[source]

Register a ROOT object to the plot.

The associated Pad is defined by pad. Properties of the object and the associated Pad can be changed via keyword arguments.

Parameters:
  • object (ROOT.TObject) – drawable ROOT object to be registered to the plot, e.g. Histo1D, TH1D, Histo2D, TH2D, Stack, …
  • pad (int) – index of the target pad (default: 0)
  • **kwargsobject, Pad properties
Print(path, **kwargs)[source]

Print the plot to a file.

Creates a Canvas and draws all registered objects into their associated Pad. The canvas is saved as a PDF/PNG/… file with the absolute path defined by path. If a file with the same name already exists it will be overwritten (can be changed with the overwrite keyword argument). If mkdir is set to True (default: False) directories in path with do not yet exist will be created automatically.

The properties of the of the plot and canvas can be configured via their respective properties passed as keyword arguments.

Parameters:
  • path (str) – path of the output file (must end with ‘.pdf’, ‘.png’, …)
  • **kwargsPlot and Canvas properties + additional properties (see below)

Keyword Arguments:

  • inject<N> (list, tuple, ROOT.TObject) – inject a (list of) drawable ROOT object(s) to pad <N> (default: 0), object properties can be specified by passing instead a tuple of the format (obj, props) where props is a dict holding the object properties (default: [])
  • overwrite (bool) – overwrite an existing file located at path (default: True)
  • mkdir (bool) – create non-existing directories in path (default: False)
Inject(pad=0, *args)[source]

Inject a (list of) drawable object(s) to the pad with index pad.

Object properties can be specified by passing instead a tuple of the format (obj, props) where props is a dict holding the object properties.

Parameters:
  • pad (int) – index of the target pad (default: 0)
  • *args (tuple, ROOT.TObject) – drawable ROOT object or tuple of the format (obj, props) where props is a dict holding the object properties
SetLabel(label)[source]

Set the plot label.

Parameters:label (str) – plot label (default: ‘ATLAS’)
GetLabel()[source]

Return the plot label.

Returntype:str
SetState(state)[source]

Set the plot state.

Parameters:label (str) – plot state (default: ‘Work In Progress’)
GetState()[source]

Return the plot state.

Returntype:str
SetCME(cme)[source]

Set the value of the center-of-mass energy.

Parameters:label (int, str) – center-of-mass energy in TeV
GetCME()[source]

Return the center-of-mass energy.

Returntype:int
SetLuminosity(lumi)[source]

Set the value of the integrated luminosity.

Parameters:label (float, str) – integrated luminosity in \(\text{fb}^{-1}\)
GetLuminosity()[source]

Return the integrated luminosity.

Returntype:float