Saving and Loading from a File

Gnuplot lets you load a series or commands in from a file. This is useful when you are trying to "tweak" a lengthy expression to get the output that you want. If you haven't used an UNIX editor before, you will probably want to start with PICO. You can start it within a terminal window by typing pico, or you can select it from the Editors menu of the Wright Hall Menu. For information on how to use Pico, see here. For instance, you might need to enter the following lines to get a graph that you want. You could put this in your home directory in a file called, for instance, "work.gnu". Then to run these commands, you would type the following in GnuPlot: Or if the file is in a differant directory, This file is on the system, if you want to try it, type The line beginning with the "#" is a comment line. You can put these in your text files as comments to yourself.

Changing Directories

If you want to put the file in another directory than your home directory, you just need to use the cd command in GnuPlot. First, to see what directory you are in, type the following: You should see something like "/user/bos", where your username is in place of "bos". To change directories, just use the cd command as follows:

Adding Pauses, Looping Animations

To make changing GnuPlot graphics, you can specify multiple plots, and just put pause statements between them. For more information, see help pause. For an example, type load '/opt/Gnu/info/gp/work2.gnu'. Also, if you put a reread statement into your text file, it causes GnuPlot to go the beginning of the file, and keep looping. For more information, see help reread, and for an example, type load '/opt/Gnu/info/gp/work3.gnu'. To exit the loop, hit Control-C in the GnuPlot window.

Saving Work

The option that GnuPlot gives for saving work is the save command. If you type the following: GnuPlot will then create a text file with the name you gave it that includes set commands for every possible setting in GnuPlot. You can then load this file to continue work where you left off.
Table of Contents - Previous - Outputing to a Graphics file - Next - Using a LogScale
College of Natural Sciences / University of Northern Iowa / manager@cns.uni.edu

Copyright © 1996 College of Natural Sciences. All Rights Reserved.
Last Modified: 11/5/96