Chapter 7. Plot Layout
Prev | Part III. Developer's Guide to PHPlot | Next

## Chapter 7. Plot Layout

This figure illustrates the plot layout, starting with PHPlot-5.0.5 when the margin calculations were rewritten. Use the following notes to help understand the figure.

- The safe_margin (box with X) is a gap of 5 pixels used to separate elements.

- The main title, X titles, and Y titles are optional. If these titles are not set, the space allocated to them collapses, including the safe_margin gap. This is shown in the figure with an arrow.

- Similarly, the X tick labels, X data labels, and Y tick labels are optional. If these labels are not used, the space allocated to them collapses, including the safe_margin.

- X data labels and X tick labels occupy the same space. Normally only one of these should be present; if both are on for some reason they will overlay.

- The base_margin (pink box with plus sign) is the space between the image edge and the outermost graphics or text. If there is no image border, or the image border is no wider than 2 pixels (which is always the case through PHPlot-5.1.1), then the base_margin is set to the same as the safe_margin value (5 pixels). A wider image border increases the base_margin; for example an 8 pixel image border results in a base_margin of 11 pixels.

- The top, left, right, and bottom margins consist of base_margin plus whatever space is needed for titles and ticks. There is a minimum value for these margins - 2 times safe_margin plus base_margin. Even if there are no titles at all on a side, the margin on that side will be no less than this minimum margin. This keeps the axis or plot area edge from coming too close to the image edge. The calculated plot area margins shown can be overridden by using SetPlotAreaPixels or SetMarginsPixels.

- The main title is positioned relative to the top of the image. Starting with PHPlot-5.0.5, the X and Y titles are positioned relative to the plot area. PHPlot-5.0.4 and earlier positioned the X and Y titles relative to the image edges. The difference should not be visible with automatic margins, but if the margins are set larger, or the plot area smaller, then the X and Y titles will move inwards with the newer releases.

- It is possible to position X ticks and X tick labels to 'xaxis', and Y ticks and Y tick labels to 'yaxis', so the ticks and/or labels will float to the axis positions rather than always appear on the edges of the plot area. Space will be allocated for the corresponding margin only if the axis happens to fall exactly at the data limits for that side. This may cause problems if the axis is close but not quite at the edge; no margin space will be allocated on that side for the labels, and the labels may overlap the title or fall off the edge of the image.

Prev | Up | Next
Part III. Developer's Guide to PHPlot | Home | Chapter 8. Legend Layout