Documentation Center

  • Trial Software
  • Product Updates

Aspect Ratio for 2-D Axes

By default, graphs display in a rectangular axes that has the same aspect ratio as the figure window. This makes optimum use of space available for plotting. You exercise control over the aspect ratio with the axis function.

For example,

t = 0:pi/20:2*pi;
plot(sin(t),2*cos(t))
grid on

produces a graph with the default aspect ratio (the same as axis normal).

  • axis square — makes the current axes region square

  • axis equal — sets the aspect ratio so that the data units are the same in every direction

  • axis equal tight — sets the aspect ratio so that the data units are the same in every direction and then sets the axis limits to the minimum and maximum values of the data.

    Note:   In order to format aspect ratio using axis, axes must exist and contain a plot. That is, you cannot pre-format an axes that has no actual x-, y-, or z-limits. To overcome this, you can preformat the axes with axis and issue the hold on command before plotting data.

Was this topic helpful?