Next: , Previous: mouse, Up: set-show


3.24.40 multiplot

The command multiplot places `gnuplot` in the multiplot mode, in which several plots are placed on the same page, window, or screen.

Syntax:

           set multiplot { layout <rows>,<cols>
                           {rowsfirst|columnsfirst} {downwards|upwards}
                           {title <page title>}
                           {scale <xscale>{,<yscale>}} {offset <xoff>{,<yoff>}}
                         }
           unset multiplot
     

For some terminals, no plot is displayed until the command multiplot is given, which causes the entire page to be drawn and then returns gnuplot to its normal single-plot mode. For other terminals, each separate `plot` command produces an updated display, either by redrawing all previous ones and the newly added plot, or by just adding the new plot to the existing display.

The area to be used by the next plot is not erased before doing the new plot. The clear command can be used to do this if wanted, as is typically the case for "inset" plots.

Any labels or arrows that have been defined will be drawn for each plot according to the current size and origin (unless their coordinates are defined in the `screen` system). Just about everything else that can be `set` is applied to each plot, too. If you want something to appear only once on the page, for instance a single time stamp, you'll need to put a `set time`/`unset time` pair around one of the `plot`, `splot` or replot commands within the multiplot/multiplot block.

The multiplot title is separate from the individual plot titles, if any. Space is reserved for it at the top of the page, spanning the full width of the canvas.

The commands origin and size must be used to correctly position each plot if no layout is specified or if fine tuning is desired. See origin and size for details of their usage.

Example:

           set multiplot
           set size 0.4,0.4
           set origin 0.1,0.1
           plot sin(x)
           set size 0.2,0.2
           set origin 0.5,0.5
           plot cos(x)
           unset multiplot
     

This displays a plot of cos(x) stacked above a plot of sin(x).

size and origin refer to the entire plotting area used for each plot. Please also see size. If you want to have the axes themselves line up, you can guarantee that the margins are the same size with the margin commands. See margin for their use. Note that the margin settings are absolute, in character units, so the appearance of the graph in the remaining space will depend on the screen size of the display device, e.g., perhaps quite different on a video display and a printer.

With the `layout` option you can generate simple multiplots without having to give the size and origin commands before each plot: Those are generated automatically, but can be overridden at any time. With `layout` the display will be divided by a grid with <rows> rows and <cols> columns. This grid is filled rows first or columns first depending on whether the corresponding option is given in the multiplot command. The stack of plots can grow `downwards` or `upwards`. Default is `rowsfirst` and `downwards`.

Each plot can be scaled by `scale` and shifted with `offset`; if the y-values for scale or offset are omitted, the x-value will be used. multiplot will turn off the automatic layout and restore the values of size and origin as they were before `set multiplot layout`.

Example:

           set size 1,1
           set origin 0,0
           set multiplot layout 3,2 columnsfirst scale 1.1,0.9
           [ up to 6 plot commands here ]
           unset multiplot
     

The above example will produce 6 plots in 2 columns filled top to bottom, left to right. Each plot will have a horizontal size of 1.1/2 and a vertical size of 0.9/3.

See also multiplot demo (multiplt.dem)