To display measurements in ROOT, including errors, there exists a powerful class
TGraphErrors with different types of constructors. In the example here, we use data from the file
ExampleData.txt in text format:
root  TGraphErrors gr("ExampleData.txt"); root  gr.Draw("AP");
You should see the output shown in Figure 2.2.
Make sure the file
ExampleData.txt is available in the directory from which you started ROOT. Inspect this file now with your favourite editor, or use the command
less ExampleData.txt to inspect the file, you will see that the format is very simple and easy to understand. Lines beginning with
# are ignored. It is very convenient to add some comments about the type of data. The data itself consist of lines with four real numbers each, representing the x- and y- coordinates and their errors of each data point.
The argument of the method
Draw("AP") is important here. Behind the scenes, it tells the
TGraphPainter class to show the axes and to plot markers at the x and y positions of the specified data points. Note that this simple example relies on the default settings of ROOT, concerning the size of the canvas holding the plot, the marker type and the line colours and thickness used and so on. In a well-written, complete example, all this would need to be specified explicitly in order to obtain nice and well readable results. A full chapter on graphs will explain many more of the features of the class
TGraphErrors and its relation to other ROOT classes in much more detail.