Gnuplot Graphing Directives

Gnuplot follows a series of configuration directives when graphing data. These directives describe rendering specifics such as the graph type, coordinate ranges, output mode (e.g., to a graphic file or to the terminal), axis labels, and the graph title. Each directive can be set via the Gnuplot interactive shell by entering gnuplot at a command prompt, or via a file that is loaded by Gnuplot. For example, the ports-per-hour data in Figure 14-2 are graphed with the following Gnuplot directives file:

$ cat figl4-2.gnu reset

© set title "psad iptables log visualization: timestamp dp:counthour" © set terminal png transparent nocrop enhanced set output "figl4-2.png" © set xdata time set timefmt x "%s" set format x "%m/%d" set xlabel "time" 0 set xrange ["1140887484":"1143867180"] set ylabel "dp:counthour" set yrange [0:3000] © plot 'figl4-2.dat' using 1:2 with lines

The most important directives in the fig14-2.gnu file above are the following:

set title The graph title at ©, which is set by psad in this case, as we'll see in the next section.

set terminal The terminal settings and output file at , which can be omitted if you want Gnuplot to launch an interactive window in which you can move a cursor over the graph. (This can be helpful when viewing complicated data sets.)

set xdata time The time setting at ©, along with the time input and output formats in the next two lines, which tell Gnuplot that the x-coordinate of each point is a time value.

set xrange The x-axis range at ©, which in this case is set to the starting and ending values of the Scan34 data set. (The time values are the number of seconds since the Unix epoch, 00:00 UTC on January 1, 1970.)

plot The plot setting at is the most important Gnuplot directive because it tells Gnuplot where the raw data is and how to graph it. In this case, a two-dimensional line graph is made of the data within the fig14-2.dat file. Other plot styles we will see in this chapter are points graphs in two and three dimensions (the splot directive puts Gnuplot in three-dimensional mode). The using 1:2 string specifies the column numbers to graph in the fig14-2.dat file; in three-dimensional mode, using 1:2:3 tells Gnuplot to plot columns 1, 2, and 3 as the x-, y-, and z- axes.

Was this article helpful?

0 0

Post a comment