라이선스가 부여된 사용자만 번역 문서를 볼 수 있습니다. 번역 문서를 보려면 로그인하십시오.

Change Axis Limits of Graph

This example shows how to change the axis limits of a graph. By default, MATLAB® chooses axis limits to encompass the data plotted.

Create Simple Line Plot

Define x as 200 linearly spaced values between -10 and 10. Define y as the sine of x with an exponentially decreasing amplitude. Create a line plot of the data.

x = linspace(-10,10,200);
y = sin(4*x)./exp(x);


Change Axis Limits

Change the axis limits by passing to the axis function a four-element vector of the form [xmin,xmax,ymin,ymax], where xmin and xmax set the scaling for the x-axis, and ymin and ymax set the scaling for the y-axis.

You also can change the axis limits using the xlim, ylim, and zlim functions. The commands xlim([xmin,xmax]) and ylim([ymin,ymax]) produce the same result as axis([xmin,xmax,ymin,ymax]).

Change the x-axis scaling to range from 0 to 10. Change the y-axis scaling to range from -1 to 1.


Use Semiautomatic Axis Limits

Use an automatically calculated minimum x-axis limit by setting its value to -inf. MATLAB® calculates the limit based on the data. Set the maximum x-axis limit to 10, the minimum y-axis limit to -1, and the maximum y-axis limit to 1.


MATLAB calculates the minimum limit for the x-axis based on the data. To use an automatically calculated maximum limit, set the value to inf.

See Also

| | | |

Related Examples

Was this topic helpful?