next up previous contents
Next: 3.6 Finding (slow) Convergence Up: 3. Exploring with a Previous: 3.4 Extending a Code

3.5 Plotting and Printing

Alice:
I have a different question. It was nice to see the orbit plotted on the screen, but I wonder how we can make a hard copy output. I would like to start gathering material to write a working paper about our project.

Carol:
That's easy, although non-intuitive. The easiest way to find out how to do this is to go into gnuplot and then to type help, and to work your way down the information about options. To give you a hint, try "set terminal" and "set output". Let me show you.

Note: because the output of the help facility of gnuplot is rather long, we will omit most of it here by printing ``......'' instead. In the example below, the words typed by Carol are help, set, terminal, postscript, then she twice hit the return key without typing anything, after which she typed output, followed again by hitting the return key twice to get back to the command level of gnuplot.

gnuplot> 
gnuplot> help
 `gnuplot` is a command-driven interactive function and data plotting program.

    . . . . . .

 The new `gnuplot` user should begin by reading about `plotting` (if on-line,
 type `help plotting`).

Help topics available:
    batch/interactive bugs              commands          comments
    coordinates       copyright         environment       expressions
    glossary          graphical         introduction      line-editing
    new-features      old_bugs          plotting          seeking-assistance
    set               show              startup           substitution
    syntax            time/date

Help topic: set
 The `set` command can be used to sets _lots_ of options.  No screen is
 drawn, however, until a `plot`, `splot`, or `replot` command is given.

 The `show` command shows their settings;  `show all` shows all the
 settings.

 If a variable contains time/date data, `show` will display it according to
 the format currently defined by `set timefmt`, even if that was not in effect
 when the variable was initially defined.

Subtopics available for set:
    angles            arrow             autoscale         bar
    bmargin           border            boxwidth          clabel
  . . . . . .
    terminal          tics              ticscale          ticslevel
    time              time/date_specifiers                timefmt
  . . . . . .

Subtopic of set: terminal
 `gnuplot` supports many different graphics devices.  Use `set terminal` to
 tell `gnuplot` what kind of output to generate. Use `set output` to redirect
 that output to a file or device.

    . . . . . .

Subtopics available for set terminal:
    aed512            aed767            aifm              bitgraph
    cgm               corel             dumb              dxf
    eepic             emtex             epson-180dpi      epson-60dpi
    epson-lx800       fig               gpic              hp2623a
    hp2648            hp500c            hpdj              hpgl
    hpljii            hppj              imagen            jpeg
    kc-tek40xx        km-tek40xx        latex             mf
    mif               mp                nec-cp6           okidata
    pbm               pcl5              png               postscript
    pslatex           pstex             pstricks          qms
    regis             selanar           starc             table
    tandy-60dpi       tek40xx           tek410x           texdraw
    tgif              tkcanvas          tpic              vttek
    x11               xlib

Subtopic of set terminal: postscript
 Several options may be set in the `postscript` driver.

    . . . . . .

 `eps` mode generates EPS (Encapsulated PostScript) output, which is just
 regular PostScript with some additional lines that allow the file to be
 imported into a variety of other applications.  (The added lines are
 PostScript comment lines, so the file may still be printed by itself.)  To
 get EPS output, use the `eps` mode and make only one plot per file.  In `eps`
 mode the whole plot, including the fonts, is reduced to half of the default
 size.
Subtopics available for set terminal postscript:
    editing           enhanced

Subtopic of set terminal postscript: 
Subtopic of set terminal: 
Subtopic of set: output
 By default, screens are displayed to the standard output. The `set output`
 command redirects the display to the specified file or device.

 Syntax:
       set output {"<filename>"}

    . . . . . .

Subtopic of set: 
Help topic: 
gnuplot> 
gnuplot> quit
|gravity>

Alice:
It is nice to have so much detailed information at your fingertips, but I'm glad you knew what to ask? I would never have guessed that I would have to give an arcane command like set terminal before adding postscript, which is what I wanted; and while set output is somewhat more logical, I wouldn't have guessed that either.

Carol:
That's what friends are for: learning to work with a new package is always easiest when looking over someone's shoulder. The first time I used gnuplot help, I did not know that you could work your way up to higher levels by simply hitting the return key. I tried quit, exit, and a number of other things, and finally killed the program. Only later I saw someone simply typing nothing, which was the solution! Okay, let's make a postscript file forward2_0.01.ps so that we can print the orbit computed by invoking forward_euler2 for step size 0.01.

Alice:
Let's make it terminal postscript eps. That way I can encapsulate the resulting postscript file directly into my working paper, as the help statement just told us.

Carol:
Fine. Note, by the way, that gnuplot does not require us to type words like terminal in full: term is fine, or even ter or te. You might guess that t would not be enough to specify, given that there are other commands starting with t, like tics. In our case, even t will work, since terminal happens to be the first command starting with a t, alphabetically, as you can see above. However, for the human reader a good compromise is set term post eps which is much easier to type than terminal postscript eps and still easily recognizable.

|gravity> gnuplot
gnuplot> plot "forward2_0.01.out"
gnuplot> set term post eps
Terminal type set to 'postscript'
Options are 'eps noenhanced monochrome dashed defaultplex "Helvetica" 14'
gnuplot> set output "forward2_0.01.ps"
gnuplot> replot
gnuplot> q
|gravity>

Carol:
Let's print it out:

|gravity> lpr "forward2_0.01.ps"
|gravity>

Alice:
Great! My first figure for my working paper. I wonder how long this paper is going to be. I guess it depends on how much patience you both have - if this is fun, I could even go on to make it a book!

Bob:
Or even a book series, for that matter?

Carol:
Don't be ironic, who knows what our first baby steps will lead to.


next up previous contents
Next: 3.6 Finding (slow) Convergence Up: 3. Exploring with a Previous: 3.4 Extending a Code
The Art of Computational Science
2004/01/25