x-y plots
This page is a stub
Remember my joke that it takes a lifetime to learn ROOT?
Prior to 2024, I only discussed making x-y plots in an advanced exercise. This was because, when I composed that section of the course 15 years ago, the documentation for TGraph and TGraphErrors was poor.
While preparing an x-y plot for the 2024 presentation (it’s on the
last slide of this PDF
file
if you’re interested), I discovered that someone on the ROOT team had
worked hard. TGraph and TGraphErrors are now no more difficult to
use than Python’s
matplotlib.
I only discovered this two days before I had to teach the tutorial!
For the 2025 class, I’ll revise this page with some examples, along with comparisons to matplotlib so you can decide which you’d prefer to use.
Until then, if you’re interested in making x-y plots in ROOT:
See the
graphssub-directory of the ROOT examples. I suggest you start with graph.C and gerrors.C.Consult the TGraphPainter web page for examples. You may also want to visit the TAttMarker, TAttLine, and TGAxis for documentation on the different plotting options.
In command-line ROOT, you can use the same tools you learned about in Walkthrough: Plotting a function and Walkthrough: Saving and printing your work to interactively edit your plot’s appearance, save it as a .C macro, then examine the macro to learn the ROOT commands to get a plot to look the way you want.
In a ROOT notebook, you can use the %jsroot magic command to make an x-y plot interactive, so you’re able to modify the plot in much the same way as in command-line ROOT. The difference is that you can’t save the plot as a .C macro… at least, not yet!
Figure 67: The x-y plot from graph.C.
There’ll be more next year!