Next: , Previous: Multiple Datasets, Up: graph


2.4 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 plots. When multiplotting, graph draws each 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 plot of a multiplot is drawn, the virtual display may be any smaller square region. The following two-plot example illustrates the idea.

     graph -T X datafile1 --reposition .35 .35 .3 datafile2

Here datafile1 is plotted in the usual way. The ‘--reposition’ option, which serves as a separator between plots, specifies that the second plot will be drawn in 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 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 X datafile1 --reposition .35 .35 .3 -w .4 -r .3 datafile2

will yield a two-plot multiplot in which the second 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 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, or whatever the background color is.) This erasure prevents the 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 plot. That is appropriate if the plot is a small one that is inset into the first plot. It may not be appropriate, however, if you are preparing a multiplot in which several 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 plot coincide with its plotting box. Specifying ‘--blankout 0.0’ will prevent any blanking out from occurring. The blankout parameter may be set more than once, so as to differ from plot to plot.

It should be emphasized that every 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 plot separately. The options for a plot should occur on the graph command line immediately after the ‘--reposition’ option that applies to it. Each plot may be prepared from more than a single dataset, also. The names of the data files for each plot should occur on the command line before the following ‘--reposition’ option, if any.