Go to the first, previous, next, last section, table of contents.


Multiplotting: placing multiple plots on a single page

It is occasionally useful to display several plots at once on a single page, or on a single graphics display. We call such a composite plot a multiplot. One common sort of multiplot is a small plot inset into a larger one. Another sort is two or more plots side by side.

graph can draw multiplots consisting of an arbitrarily large number of sub-plots. When multiplotting, graph draws each sub-plot in its own `virtual display'. When an ordinary plot is drawn, the virtual display is the same as the physical display. But when a multiplot is drawn, the virtual display may be any smaller square region. The following example illustrates the idea.

graph -T ps data_file_1 --reposition .35 .35 .3 data_file_2

Here data_file_1 is plotted in the usual way. The `--reposition' option specifies that when data_file_2 is plotted, it will be drawn within a virtual display. For the purposes of the `--reposition' option, the physical display is a square with lower left corner (0.0,0.0) and upper right corner (1.0,1.0). In those coordinates, the virtual display will be a square of size 0.3 with lower left corner (0.35,0.35). So the second sub-plot will be inset into the first.

Just as the `-w', `-h', `-r', and `-u' options may be used to set the size and position of a plotting box within the physical display, so they may be used to set the size and position of a plotting box within a virtual display. For example,

graph -T ps data_file_1 --reposition .35 .35 .3 -w .4 -r .3 data_file_2

will yield a multiplot in which the second sub-plot is significantly different. Its plotting box will have a width only 0.4 times the width of the virtual display. However, the plotting box will be centered within the virtual display, since the distance between the left edge of the plotting box and the left edge of the virtual display will be 0.3 times the width of the virtual display.

By convention, before each sub-plot of a multiplot other than the first is drawn, a `blankout region' surrounding its plotting box is erased. (That is, it is filled with white.) This erasure prevents the sub-plots from overlapping and producing a messy result. By default, the blankout region is a rectangular region 30% larger in each dimension than the plotting box for the sub-plot. This is appropriate if the sub-plot is a small one that is inset into the first sub-plot. It may not be appropriate, however, if you are preparing a multiplot in which several sub-plots appear side by side. You may use the `--blankout' option to adjust this parameter. For example, specifying `--blankout 1.0' will make the blankout region for a sub-plot coincide with its plotting box. Specifying `--blankout 0.0' will prevent any blanking out from occurring. The blankout parameter may differ from sub-plot to sub-plot.

It should be emphasized that every sub-plot in a multiplot is a plot in its own right. All the usual options (`-m', `-S', `-x', `-y', etc.) can be applied to each sub-plot separately. The options for a sub-plot should occur on the graph command line immediately after the `--reposition' option that applies to it. Each sub-plot may be prepared from more than a single dataset, also. The names of the data files for each subplot should occur on the command line before the following `--reposition' option, if any.


Go to the first, previous, next, last section, table of contents.