Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

box

Display axes outline

Syntax

box on
box off
box
box(ax,___)

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'. This option is the default behavior.

box toggles the display of the box outline.

example

box(ax,___) uses the axes specified by ax instead of the current axes. Specify the axes as the first input argument for any of the previous syntaxes. Use single quotes around the 'on' and 'off' inputs, such as box(ax,'on').

Examples

collapse all

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

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';

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';

Create a figure with two subplots and assign the Axes objects to the variables ax1 and ax2. Plot a line in each subplot. Remove the box outline around the lower subplot by specifying ax2 as the first input argument to box.

ax1 = subplot(2,1,1);
plot(ax1,1:10)

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

Input Arguments

collapse all

Target axes, specified as an Axes object or a PolarAxes object. If you do not specify the axes, then box affects the current axes.

Tips

  • Some Cartesian axes properties affect the appearance of the box outline. This table lists a subset of axes properties related to the box outline.

    Axes PropertyDescription
    BoxDisplay of box outline
    BoxStyleStyle of box outline
    XColor, YColor, ZColorBox outline color in the x-axis, y-axis, and z-axis directions
    LineWidthWidth of box outline, tick marks, and grid lines

  • Some polar axes properties affect the appearance of the outline around the polar axes. If you are working with polar axes, then the box command controls the outline display when the theta-axis limits do not span 360 degrees. This table lists a subset of polar axes properties related to the outline.

    PolarAxes PropertyDescription
    BoxDisplay of full outline
    RColor, ThetaColorOutline color
    LineWidthWidth of outline, tick marks, and grid lines

Algorithms

The box function sets the Box property of the Axes or PolarAxes object to either 'on' or 'off'.

See Also

Functions

Properties

Introduced before R2006a

Was this topic helpful?