Gnuplot shows 2 or 3D graphs. As input it allows scripts or data tables. As output it can visualize the data and store it into commonly used picture formats. Gnuplot is interactively. Type gnuplot and then a prompt appears where you can type in a formula to be interactively visualized using the plot command as plot sin(x)/x

Figure 10.2. gnuplot


To visualize data from a table, a file containing the data is required. The extension .dat is commonly used for such files. The file is a regular text file where the data columns are separated by space characters or tab. Using # allows to insert comments as the title section of the file.After typing gnuplot and having the prompt type plot "oven.dat" using 1:2 title 'Temperature'

Figure 10.3. Oven


After seeing the basics, some advanced stuff to know are:

  1. To exit type quit

  2. While seeing the graphics, additional commands can be inserted into the console windows.

  3. The commands typed into the console can be stored into a file to have a gnuplot script. To not have gnuplot interactive, start it with the script: gnuplot -p <script>. The script runs and gnuplot exits. The -p option keeps the graphical window alive when gnuplot exits.

  4. Since it is interactively you can zoom in with the mouse and give some hot key commands as u for zoom out, g to show the grid and h for help on that feature.

  5. To convert the output into a file requires some commands as

    set terminal <postscript or png>
    set output "<filename>.<extension>"

    The first command set terminal selects the output format. The second deviates to a file and the third re-plots the graph into the file. Gnuplot does not handle directly fonts and this might cause the set terminal command to fail. Postscript and jpeg are not critical formats. After having the file it can easily be converted in other formats.

  6. The environmental variables GDFONTPATH and GNUPLOT_DEFAULT_GDFONT can be used to solve font problems

Linurs Servernest startpage