Graph

class Graph.Graph(name='Graph_5ee80fb0', *args, **kwargs)[source]

Bases: MethodProxy.MethodProxy, TGraphAsymmErrors

Class for displaying arrays of 2-dimensional coordinates.

Inherits from ROOT.TGraphAsymmErrors, see official documentation as well!

In order to avoid memory leaks, name is an inaccessible property despite having corresponding getter and setter methods. Furthermore the properties xtitle, ytitle and ztitle are defined to be exclusive to the Pad class.

__init__(name='Graph_5ee80fb0', *args, **kwargs)[source]

Initialize a graph.

Create an instance of Graph with the specified name from two arrays of equal length.

Parameters:
  • name (str) – name of the graph
  • *args – see below
  • **kwargsGraph properties
Arguments:

The first and optional argument is title of the graph given by a str.

Depending on the total number of arguments (besides name and the optional title) there are two ways to initialize a Graph object:

  • one argument:

    1. graph (Graph, TGraph, TGraphAsymmErrors) – graph to be copied
  • two arguments:

    1. xvalues (list) – list of x-values which can be either of type float or tuple/list; in the latter case depending on the length of the tuple/list the entries are interpreted as:

      1. nominal x-value
      2. nominal x-value, (sym.) uncertainty
      3. nominal x-value, up-, down-uncertainty
    2. yvalues (list) – list of y-values which can be either of type float or tuple/list (see above)

Print(path, **kwargs)[source]

Print the graph to a file.

Creates 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 styling of the graph, pad 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’, …)
  • **kwargsGraph, Plot, Canvas and Pad properties + additional properties (see below)

Keyword Arguments:

  • inject (list, tuple, ROOT.TObject) – inject a (list of) drawable ROOT object(s) to the main 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 (default: [])
  • overwrite (bool) – overwrite an existing file located at path (default: True)
  • mkdir (bool) – create non-existing directories in path (default: False)
SetDrawOption(option)[source]

Define the draw option for the graph.

Parameters:option (str) – draw option (see ROOT.TGraphPainter class reference)
GetDrawOption()[source]

Return the draw option defined for the graph.

Returntype:str
GetPoint(index, *args)[source]

Return the x- and y-value for a given index if no other arguments are given. Otherwise the standard ROOT.TGraph.GetPoint() functionality is used.

Parameters:
  • index (int) – index of the coordinate point
  • *args – see ROOT documentation of ROOT.TGraph.GetPoint()
Returntype:

tuple for call with no additional arguments, else None