Using MATLAB Graphics     Search    Help Desk 

Example - Readjusting PaperPosition

This example shows you how to recalculate paper position to achieve a specific layout.

Problem

You are working with figure windows of varying sizes and shapes and you want to determine the values to use for the PaperPosition property to print each one:

Solution

To solve this problem in the general case, you need to know the values of the figure's Position and PaperSize properties, being careful to use the same units for all dimensions. With this information you can decide how to orient the paper and/or scale the figure size to fit properly.

Suppose a particular figure is five inches wide and three and one-half inches high and you want to print it on the default size paper at your site. You need to calculate a new value for PaperPosition based on these sizes.

Obtain the size of the figure and the paper, in inches.

Since the figure is wider than it is high, the width limits the maximum size that fits on the page. Furthermore, since the figure is smaller than the paper, you can set the PaperPosition width to the paper width minus a one-quarter inch border on both sides.

Calculate the PaperPosition height in terms of the width, maintaining the correct aspect ratio.

To determine the offset from the bottom of the paper, subtract the new PaperPosition height (i.e., the printed height of the figure) from the paper height, taking one-half this value to center the figure on the page from top to bottom.

The offset from the left is simply the border width.

You have now fully specified the PaperPosition for this particular figure,

and can set the property for printing.



[ Previous | Help Desk | Next ]