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

Display Text Outside Axes

This example shows how to display text outside an axes by creating a second axes for the text. MATLAB® always displays text objects within an axes. If you want to place a text description alongside an axes, then you must create another axes to position the text.

Create an invisible axes, ax1, that encompasses the entire figure window by specifying its position as [0,0,1,1]. Then, create a smaller axes, ax2, to contain the actual plot. Create a line plot in the smaller axes by passing its axes handle, ax2, to the plot function.

fig = figure;
ax1 = axes('Position',[0 0 1 1],'Visible','off');
ax2 = axes('Position',[.3 .1 .6 .8]);

t = 0:1000;
y = 0.25*exp(-0.005*t);

Define the string for the text description. Use a cell array to define multiline text.

descr = {'Plot of the function:';
    'y = A{\ite}^{-\alpha{\itt}}';
    ' ';
    'With the values:';
    'A = 0.25';
    '\alpha = .005';
    't = 0:1000'};

Set the larger axes to be the current axes since the text function places text in the current axes. Then, display the text.

axes(ax1) % sets ax1 to current axes

The figure contains text next to the line plot.

Was this topic helpful?