Plotting

The plotting class is composed of the TH1F, TH2F and TLine classes. These names are taken from the CERN ROOT framework and are used as wrappers for boost-histograms and MPL-HEPP.

Plotting Base Function used to Share Attributes

class AnalysisG.core.plotting.BasePlotting
Variables:
  • Hatch (str) – Changes the texture of figures.

  • DPI (int) – Changes the output resolution of the figure.

  • Style (str) – The template style to use (ATLAS, ROOT, etc.)

  • ErrorBars (bool) – Indicates whether to show error bars on the histogram bins.

  • Filename (str) – Specifies the output filename for the plot.

  • OutputDirectory (str) – Specifies the output directory for the plot.

  • FontSize (float) – Specifies the font size to be used by matplotlib.

  • AxisSize (float) – Specifies the axis-title font size.

  • LegendSize (float) – Specifies the size of the legend shown on plots.

  • TitleSize (float) – Specifies the title size shown on plots.

  • UseLateX (bool) – Whether to parse mathematical symbols via latex.

  • xScaling (float) – Specify the image scaling in the x-direction.

  • yScaling (float) – Specify the image scaling in the y-direction.

  • AutoScaling (bool) – Whether to use matplot lib’s magic to find the optimal scaling.

  • Title (str) – The title given for the plot.

  • xTitle (str) – The title given to the x-axis.

  • yTitle (str) – The title given to the y-axis.

  • xLogarithmic (bool) – Whether to scale the x-axis logarithmically.

  • yLogarithmic (bool) – Whether to scale the y-axis logarithmically.

  • xStep (float) – Specifies the step size of the x-axis ticks.

  • yStep (float) – Specifies the step size of the y-axis ticks.

  • xMin (float) – Specifies the minimum value of the plots x-axis.

  • yMin (float) – Specifies the minimum value of the plots y-axis.

  • xMax (float) – Specifies the maximum value of the plots x-axis.

  • yMax (float) – Specifies the maximum value of the plots y-axis.

SaveFigure()

A function call used to save the figure.

Histogramming using TH1F

class AnalysisG.core.plotting.TH1F(BasePlotting)
Variables:
  • xData (list[float]) – Assigns the values that should be used to fill the histogram.

  • xBins (int) – Number of bins to use for the histogram.

  • CrossSection (float) – A variable used to specify the cross section of the process, which scales the histogram accordingly.

  • IntegratedLuminosity (float) – The integrated luminosity used to scale the histogram.

  • HistFill (str) – A parameter used to modify the fill type of the histogram.

  • Stacked (bool) – Whether to plot a stacked histogram.

  • LineWidth (float) – Specifies the line width of the histograms.

  • Alpha (float) – Controls the transparency of the histograms.

  • Density (bool) – Whether to plot the histogram as a density.

  • xLabels (dict) – Labels to apply on the x-axis with specified weight values.

Histogramming using TH2F

class AnalysisG.core.plotting.TH2F(BasePlotting)
Variables:
  • xData (list[float]) – Assigns the values that should be used to fill along the x-axis.

  • yData (list[float]) – Assigns the values that should be used to fill along the y-axis.

  • xBins (int) – Number of bins to use along the x-axis.

  • yBins (int) – Number of bins to use along the x-axis.

Example: A simple TH1F plot

from AnalysisG.core.plotting import TH1F

th = TH1F()
th.xBins = 100
th.xMax = 100
th.xMin = 0
th.xData = [i for i in range(100)]
th.Title = "some title"
th.xTitle = "x-Axis"
th.yTitle = "y-Axis"
th.Filename = "some-name"
th.OutputDirectory = "./Some/Path/"
th.SaveFigure()

Example: Combining two or more TH1F plots

from AnalysisG.core.plotting import TH1F

# Define the settings to apply to all histograms
th = TH1F()
th.xMin = 0
th.xStep = 20
th.xMax = 100
th.Title = "some title"
th.xTitle = "x-Axis"
th.yTitle = "y-Axis"
th.Filename = "some-name"
th.OutputDirectory = "./Some/Path/"

# Iterate over your data
for i in MyDataDictionary:

    # Create a new TH1F instance
    th_ = TH1F()
    th_.Title = i

    # Populate this instance with some data
    th_.xData = MyDataDictionary[i]

    # Append the instance to the Histograms attribute
    th.Histograms.append(th_)

th.SaveFigure()

Example: A Simple TH2F Plot

from AnalysisG.core.plotting import TH2F

th2 = TH2F()
th2.Title = "Some distribution plot"
th2.xTitle = "x-Title"
th2.yTitle = "y-Title"

th2.xMin = 0
th2.yMin = 0

th2.xMax = 100
th2.yMax = 100

th2.xBins = 100
th2.yBins = 100

th2.xData = [i for i in range(100)]
th2.yData = [i for i in range(100)]
th2.Filename = "Some_File"
th2.OutputDirectory = "./some/path"
th2.SaveFigure()