# Python Walkthrough: Simple analysis using the Draw command, part 2 (10 minutes)

Instead of just plotting a single variable, let’s try plotting two variables at once:

tree1.Draw("ebeam:px")
my_canvas.Draw()


Note

This is a scatterplot, a handy way of observing the correlations between two variables. The Draw command interprets the variables as (“y:x”) to decide which axes to use.

It’s easy to fall into the trap of thinking that each (x,y) point on a scatterplot represents two values in your n-tuple. The scatterplot is a grid; each square in the grid is randomly populated with a density of dots proportional to the number of values in that square.

Try making scatterplots of different pairs of variables. Do you see any correlations?

Note

If you see a shapeless blob on the scatterplot, the variables are likely to be uncorrelated; for example, plot px versus py. If you see a pattern, there may be a correlation; for example, plot pz versus zv. It appears that the higher pz is, the lower zv is, and vice versa. Perhaps the particle loses energy before it is deflected in the target.

Let’s create a “cut” (a limit on the range of a variable):

tree1.Draw("zv","zv<20")
my_canvas.Draw()


Look at the x-axis of the histogram. Compare this with:

tree1.Draw("zv")
my_canvas.Draw()


Note

Note that ROOT determines an appropriate range for the x-axis of your histogram. Enjoy this while you can; this feature is lost when you start using analysis scripts.1

A variable in a cut does not have to be one of the variables you’re plotting:

tree1.Draw("ebeam","zv<20")


Try this with some of the other variables in the tree.

ROOT’s symbol for logical AND is &&. Try using this in a cut, e.g.:

tree1.Draw("ebeam","px>10 && zv<20")


1

After this point, I won’t include the my_canvas.Draw() line in future examples, and you’ll have to remember to execute that line. I assume you’ve gotten into the habit of re-using or cut-and-pasting lines between cells.