# Graphs and plots

## Gnuplot graphs

A separate program, gnuplot, is called to generate graphs. Gnuplot is a very full-featured graphing program with myriad options. It is available from www.gnuplot.info (but note that a copy of gnuplot is bundled with the MS Windows version of gretl). gretl gives you direct access, via a graphical interface, to a subset of gnuplot's options and it tries to choose sensible values for you; it also allows you to take complete control over graph details if you wish.

With a graph displayed, you can click on the graph window for a pop-up menu with the following options.

- Save as PNG: Save the graph in Portable Network Graphics format.

- Save as postscript: Save in encapsulated postscript (EPS) format.

- Save as Windows metafile: Save in Enhanced Metafile (EMF) format.

- Save to session as icon: The graph will appear in iconic form when you select "Icon view" from the Session menu.

- Zoom: Lets you select an area within the graph for closer inspection (not available for all graphs).

- Print: On the Gnome desktop only, lets you print the graph directly.

- Copy to clipboard: MS Windows only, lets you paste the graph into Windows applications such as MS Word. For best results when pasting graphs into MS Office applications, choose the application's Edit, Paste Special... menu item, and select the option Picture (Enhanced Metafile).

- Edit: Opens a controller for the plot which lets you adjust various aspects of its appearance.

- Close: Closes the graph window.

If you know something about gnuplot and wish to get finer control over the appearance of a graph than is available via the graphical controller (Edit option), you have two further options.

- Once the graph is saved as a session icon, you can right-click on its icon for a further pop-up menu. One of the otions here is Edit plot commands, which opens an editing window with the actual gnuplot commands displayed. You can edit these commands and either save them for future processing or send them to gnuplot (with the File/Send to gnuplot menu item in the plot commands editing window).

- Another way to save the plot commands (or to save the displayed plot in formats other than EPS or PNG) is to use Edit item on a graph's pop-up menu to invoke the graphical controller, then click on the Output to file tab in the controller. You are then presented with a drop-down menu of formats in which to save the graph.

To find out more about gnuplot see the online manual or www.gnuplot.info.

See also the entry for `gnuplot` in below — and the `graph` and `plot` commands for quick and dirty ASCII graphs.

### gretl's gnuplot controller

gnuplot controller

## Boxplots

Boxplots are not generated using gnuplot, but rather by gretl itself.

These plots (after Tukey and Chambers) display the distribution of a variable. The central box encloses the middle 50 percent of the data, i.e. it is bounded by the first and third quartiles. The whiskers extend to the minimum and maximum values. A line is drawn across the box at the median.

In the case of notched boxes, the notch shows the limits of an approximate 90 percent confidence interval. This is obtained by the bootstrap method, which can take a while if the data series is very long.

Clicking the mouse in the boxplots window brings up a menu which enables you to save the plots as encapsulated postscript (EPS) or as a full-page postscript file. Under the X window system you can also save the window as an XPM file; under MS Windows you can copy it to the clipboard as a bitmap. The menu also gives you the option of opening a summary window which displays five-number summaries (minimum, first quartile, median, third quartile, maximum), plus a confidence interval for the median if the notched option was chosen.

Some details of gretl's boxplots can be controlled via a (plain text) file named `.boxplotrc` which is looked for, in turn, in the current working directory, the user's home directory (corresponding to the environment variable `HOME`) and the gretl user directory (which is displayed and may be changed under the File, Preferences, General menu). Options that can be set in this way are the font to use when producing postscript output (must be a valid generic postscript font name; the default is Helvetica), the size of the font in points (also for postscript output; default is 12), the minimum and maximum for the y-axis range, the width and height of the plot in pixels (default, 560 x 448), whether numerical values should be printed for the quartiles and median (default, don't print them), and whether outliers (points lying beyond 1.5 times the interquartile range from the central box) should be indicated separately (default, no). Here is an example:

    font = Times-Roman
    fontsize = 16
    max = 4.0
    min = 0
    width = 400
    height = 448
    numbers = %3.2f
    outliers = true

On the second to last line, the value associated with `numbers` is a printf format string as in the C programming language; if specified, this controls the printing of the median and quartiles next to the boxplot, if no `numbers` entry is given these values are not printed. In the example, the values will be printed to a width of 3 digits, with 2 digits of precision following the decimal point.

Not all of the options need be specified, and the order doesn't matter. Lines not matching the pattern key = value are ignored, as are lines that begin with the hash mark, `#`.

After each variable specified in the boxplot command, a parenthesized boolean expression may be added, to limit the sample for the variable in question. A space must be inserted between the variable name or number and the expression. Suppose you have salary figures for men and women, and you have a dummy variable `GENDER` with value 1 for men and 0 for women. In that case you could draw comparative boxplots with the following line in the boxplots dialog:

          salary (GENDER=1) salary (GENDER=0)