Gnuplot

Notes on Gnuplot

## Plotting

using the file toy1.ascii, and the gnuplot script plot.p I made the following images with gnuplot. You would make these same plots by starting gnuplot in a terminal, then typing at the prompt:

Be sure that you've downloaded the file and the script into the directory that you are running gnuplot from.

Brief explanation of what the script is doing…

set title "Title of Plot"
set autoscale

set xlabel "X-Axis Label"
set ylabel "Y-Axis Label"

The top of the code sets the Title that will show up on each successive plot.
Setting autoscale has gnuplot determine what the x and y ranges should be (to tell it specifics: set xrange [4000:4002], etc.)

Setting the x and y axis labels

p"toy1.ascii"us 2:3w l

Notice that there are shortcuts being used, this command in full form is:

plot "toy1.ascii" using 2:3 with lines

And is telling gnuplot to plot the file toy1.ascii, using column 2 as the x values, and column 3 as the y values, and connect the points with a line

p"toy1.ascii"i 0us 2:3w l

(You can comment a line out of a gnuplot script with a hash "#" (gnuplot doesn't do anything with the line))

# previous line in expanded form
#plot "toy1.ascii" index 0 using 2:3 with lines

The only thing different here is the use of an "index" — notice in the toy1.ascii file that there are 2 blank lines that break the data up. This signifies an index break, and gnuplot starts counting with 0.

Gnuplot will interpret a single blank line as a "lift the pen" command.

p"toy1.ascii"i 0us 2:3w l,""i 1us 2:3w l
#plot "toy1.ascii" index 0 using 2:3 with lines,"" index 1 using 2:3 with lines

There are two things different here. First you are plotting 2 things now: after the comma, gnuplot plots the next thing in the line. If I had a different file name with data I wanted to plot on top, I would have put that file name in quotes, but since I'm using the same file, I can just put empty "" to tell it "we are in the same file".

p"toy1.ascii"i 1us 2:3w l,""i 1us 2:4w l

#plot "toy1.ascii" index 1 using 2:3 with lines,""index 1 using 2:4 with lines

p"toy1.ascii"i 1us 2:($3/$6)w l,""i 1us 2:($4/$6)w l

p"toy1.ascii"i 1us 2:($3/$6)w l ti"Normalized Flux Data",""i 1us 2:($4/$6)w l ti"Errors"

#plot "toy1.ascii" index 1 using 2:($3/$6) with lines title "Normalized Flux Data","" index 1 using 2:($4/$6) with lines title "Errors"

To do a few things that are a bit trickier…

to plot 2 files' columns:

plot "< paste noI2full67.ascii I2full67.ascii" using 2:($3/$6-$9/$12) with lines

plotting data separated by 2 white lines

plot "file.ascii" index 0 using 1:2 with lines

plotting data with asymmetric errorbars:

p"ryan.ascii"using 1:2:($2+$3):($2-$4) w yerrorbars

## Multiplot Multiple plots

set term gif

Terminal type set to 'gif'
Options are 'nocrop medium '