# box

Display axes outline

## Syntax

• ``box on``
example
• ``box off``
• ``box``
• ``box(ax,___)``
example

## Description

example

````box on` displays the box outline around the current axes. This option sets the `Box` property of the current axes to `'on'`.```
````box off` does not the display the box outline around the current axes. This option sets the `Box` property of the current axes to `'off'`.```
``box` toggles the display of the box outline.`

example

````box(ax,___)` uses the axes specified by `ax` instead of the current axes (`gca`). Specify `ax` as a scalar axes object. You can specify an axes with any of the input arguments in the previous syntaxes. Use single quotes around input arguments that are character strings, for example, `box(ax,'on')` and `box(ax,'off')`.```

## Examples

collapse all

### Display Box Outline Around Axes

Plot a surface and display the box outline around the axes.

```[X,Y,Z] = peaks; surf(X,Y,Z) box on ```

Turn off the display of the box outline.

```box off ```

### Change Style of Box Outline

First, plot a surface and display the box outline around the axes. By default, the outline appears around the back planes of the axes because the `BoxStyle` property of the axes is set to `'back'`.

```[X,Y,Z] = peaks; surf(X,Y,Z) box on ```

Next, display the outline around the entire axes by setting the `BoxStyle` property to `'full'`. Starting in R2014b, you can use dot notation to set properties. If you are using an earlier release, use the `set` function instead.

```ax = gca; ax.BoxStyle = 'full'; ```

### Change Color of Box Outline

Create a scatter plot and display the box outline around the axes.

```x = rand(10,1); y = rand(10,1); scatter(x,y) box on ```

Change the color of the box outline in the x-axis direction by setting the `XColor` property of the axes. Starting in R2014b, you can use dot notation to set properties. If you are using an earlier release, use the `set` function instead.

```ax = gca; ax.XColor = 'red'; ```

### Turn Off Box Outline for Specific Axes

Create a figure with two subplots and return the axes objects. Plot a line in each subplot. Turn off the display of the box outline around the axes for the lower subplot.

```ax1 = subplot(2,1,1); plot(1:10) ax2 = subplot(2,1,2); plot(1:10) box(ax2,'off') ```

expand all