(xyplots)= # x-y plots :::::{admonition} This page is a stub :class: warning Remember my joke that it takes a lifetime to learn ROOT? Prior to 2024, I only discussed making x-y plots in an {ref}`advanced exercise `. This was because, when I composed that section of the course 15 years ago, the documentation for [TGraph](https://root.cern.ch/doc/master/classTGraph.html) and [TGraphErrors](https://root.cern.ch/doc/master/classTGraphErrors.html) was poor. While preparing an x-y plot for the 2024 presentation (it's on the last slide of [this PDF file](https://www.nevis.columbia.edu/~seligman/root-class/ClassOverview2024.pdf) 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](https://matplotlib.org/stable/users/index). 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 {file}`graphs` sub-directory of the {ref}`ROOT examples `. I suggest you start with [graph.C](https://root.cern/doc/master/graph_8C.html) and [gerrors.C](https://root.cern/doc/master/gmultierrors_8C.html). - Consult the [TGraphPainter](https://root.cern.ch/doc/master/classTGraphPainter.html) web page for examples. You may also want to visit the [TAttMarker](https://root.cern.ch/doc/master/classTAttMarker.html), [TAttLine](https://root.cern.ch/doc/master/classTAttLine.html), and [TGAxis](https://root.cern.ch/doc/master/classTGAxis.html) for documentation on the different plotting options. - In command-line ROOT, you can use the same tools you learned about in {ref}`plotting-function` and {ref}`saving-c1` 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 {ref}`notebook `, you can use the {ref}`%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-md} xyplot-fig :align: center x-y plot from graph.C The x-y plot from {file}`graph.C`. ::: There'll be more next year! :::::