Recently, I've been doing rather a lot of R-matrix analysis. In short this means I'm trying to understand the probability of nuclear reactions occurring as a function of both energy and scattering angle. The gnuplot splot command is great for viewing the calculations and data as a function of two variables, and makes fitting the data much easier.

In this case, the agreement between the curve and the points isn't fantastic, but it simply isn't clear which point should be compared to which line. You can't easily distinguish both the x and y coordinates of each point. Even interactively rotating the plot doesn't help much when the point density is this high.

The tip here is to colour the points and calculations to help depth perception. Adding the palette option to the splot command will colour by a fourth variable that is appended to the column specification. Here's the sample code:

In this case, all the data is in data.dat. Columns 1 and 3 contain the energy and angle respectively. Column 4 and 6 contain the data points and the calculations. The fourth specifier (3) tells gnuplot to colour things by the angle - in this case, the y-axis variable. The resulting plot looks like this:

However, with many data points, depth perception can get a little tricky. For example, a typical plot might look something like this:

In this case, the agreement between the curve and the points isn't fantastic, but it simply isn't clear which point should be compared to which line. You can't easily distinguish both the x and y coordinates of each point. Even interactively rotating the plot doesn't help much when the point density is this high.

The tip here is to colour the points and calculations to help depth perception. Adding the palette option to the splot command will colour by a fourth variable that is appended to the column specification. Here's the sample code:

setterminal png enhanced size 800,600 font "sans, 16"

setxlabel "Energy (MeV)"

setylabel "Angle (degrees)" offset 0,-1,0

setzlabel "Cross section (mb)" rotate by 90

setpalette model RGB defined ( 0.0 'black', 0.3 'purple', 0.5 "blue", 0.7 "green", 0.9 "orange", 1.0 "red" )

setoutput "splotting.png"

splot"data.dat" u 1:3:6:3 w p ps 1 palette notitle,\

"data.dat" u 1:3:4:3 w l lw 2 palette notitle

In this case, all the data is in data.dat. Columns 1 and 3 contain the energy and angle respectively. Column 4 and 6 contain the data points and the calculations. The fourth specifier (3) tells gnuplot to colour things by the angle - in this case, the y-axis variable. The resulting plot looks like this:

It is now clear which lines should be compared to which points. The palette option certainly makes for prettier splots and can be really useful for improving their readability. The range of colours can be tuned in each case using the

**set**palette model command to match the spread of your data to make things as clear as possible.