Credits | Overview | Plotting Styles | Commands | Terminals
--- | --- | --- | --- | ---

## layers

A gnuplot plot is built up by drawing its various components in a fixed order. This order can be modified by assigning some components to a specific layer using the keywords behind, back, or front. For example, to replace the background color of the plot area you could define a colored rectangle with the attribute behind.

         set object 1 rectangle from graph 0,0 to graph 1,1 fc rgb "gray" behind

The order of drawing is

         behind
         back
         the plot itself
         the plot legend (`key`)
         front

Within each layer elements are drawn in the order

         grid, axis, and border elements
         pixmaps in numerical order
         objects (rectangles, circles, ellipses, polygons) in numerical order
         labels in numerical order
         arrows in numerical order

In the case of multiple plots on a single page (multiplot mode) this order applies separately to each component plot, not to the multiplot as a whole.

An exception to this is that several TeX-based terminals (e.g. pslatex, cairolatex) accumulate all text elements in one output stream and graphics in a separate output stream; the text and graphics are then combined to yield the final figure. In general this leaves each text element either completely behind or completely in front of the graphics.