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.
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()