This lesson is being piloted (Beta version)

Matplotlib for HEP: Glossary

Key Points

Introduction
  • Matplotlib graphs data in Figures, each of which can contain components that can be manipulated: axis, legend, labels, etc.

  • Many kinds of plots can be produced: scatter plots, bar plots, pie charts, and many more

  • HEP styling is available via the mplhep package, with recommended plotting styles from LHC experiments

  • Matplotlib can take objects containing data and bin them to produce histograms (which are very common in HEP)

  • Check the Matplotlib documentation for getting details on all the available options

Coffee break
Physics background
  • Analysis studies Higgs boson decays

Higgs search
  • In High-energy physics, histograms are used to analyze different data and MC distributions.

  • With Matplotlib, data can be binned and histograms can be plotted in a few lines.

  • Using Uproot and Matplotlib, data in ROOT files can be display without need of a full ROOT installation.

  • Histograms can be stacked and/or overlapped to make comparison between recorded and simulated data.

Plotting with mplhep for HEP style plotting
  • Mplhep is a wrapper for easily apply plotting styles approved in the HEP collaborations.

  • Styles for LHC experiments (CMS, ATLAS, LHCb and ALICE) are available.

  • If you would like to include a style for your collaboration, ask for it opening an issue!

Coffee break
Dimuon spectrum
  • Any data format that can be loaded as an object in Python can be plotted using Matplotlib.

  • Not always the default values will provide meaningful plots. When needed try to zoom changing the ranges in the distributions.

  • When in doubt, check the documentation! The web is also full of good examples.

Glossary

The important parts of a plot are summarized in the image below Names for different parts of a matplotlib plot