Graphics  Printing a Centered Figure

This example sets the size of a figure to 5.5-by-3 inches and centers it on the paper.

Using the Graphical User Interface

1. Select Page Setup from the figure window's File menu, and select the Size and Position tab.
2. Make sure Use manual size and position is selected.
3. Enter `5.5` in the Width field and `3` in the Height field.
4. Make sure that Units field is set to `inches`.
5. Click Center.
6. Click OK.
7. Open the Print dialog box and print the figure.

Using MATLAB Commands

1. Start by setting `PaperUnits` to `inches`.
• ```set(gcf, 'PaperUnits', 'inches')
```
2. Use `PaperSize` to return the size of the current paper.
• ```papersize = get(gcf, 'PaperSize')

papersize =
8.5000   11.0000
```
3. Initialize variables to the desired width and height of the figure.
• ```width = 5.5;         % Initialize a variable for width.
height = 3;          % Initialize a variable for height.
```
4. Calculate a left margin that centers the figure horizontally on the paper. Use the first element of `papersize` (width of paper) for the calculation.
• ```left = (papersize(1)- width)/2

left =
1.5000
```
5. Calculate a bottom margin that centers the figure vertically on the paper. Use the second element of `papersize` (height of paper) for the calculation.
• ```bottom = (papersize(2)- height)/2

bottom =
4
```
6. Set the figure size and print.
• ```myfiguresize = [left, bottom, width, height];
set(gcf, 'PaperPosition', myfiguresize);
print
``` Printing with a Specific Paper Size Exporting in a Specific Graphics Format © 1994-2005 The MathWorks, Inc.