13. Data exercise

Look at this page from the Particle Data Group. It has plots and data files for the total collision cross section of \(\pi^-p\) and \(\pi^+p\) collisions. Instead of the two separate plots, we would like to have both lines on a single figure.

Using the command line tools we discussed in the previous sessions, you should download the data files, extract the relevant columns and produce a plot using gnuplot. We’ll introduce other plotting tools for data sets later.

Gnuplot expects a data file with one plot point per line, in six columns: each line should contain the points with error bar information in the format x y xlow xhigh ylow yhigh. Convert the data files from the PDG website into this format. (awk from previous weeks will be useful, it lets you calculate with column references: $2 + $3).

After converting the data into the correct format, a simple gnuplot session looks like:

$ gnuplot
[... some splash text ...]
gnuplot> set logscale
gnuplot> plot 'filename1' with xyerrorbars, 'filename2' with xyerrorbars
gnuplot> quit

Instead of entering these instructions into a gnuplot session one by one, you can also save them in a file, say plot.gnu, and call:

$ gnuplot plot.gnu

To create the plot in a PDF file which you can import in a \(\LaTeX\) document, call:

set terminal pdf
set output 'foo.pdf'

before the plot command. gnuplot has very detailed information accessible through its help command.