您正在寻找的功能称为
annotation.
例如,注释(‘textbox’,[x y w h])创建一个可编辑的文本框注释,其左下角位于点x,y,宽度w和高度h,以标准化的图形单位指定.在单个向量中指定x,y,w和h.
这里有一些钟声和口哨的示范……
x=0:0.1:10;
var=1.85;
y=x.^(var);
plot(x,y);
annotation('textbox',...
[0.15 0.65 0.3 0.15],...
'String',{'plotting y=x^{var} ,',['with var =' num2str(var)]},...
'FontSize',14,...
'FontName','Arial',...
'LineStyle','--',...
'EdgeColor',[1 1 0],...
'LineWidth',2,...
'BackgroundColor',[0.9 0.9 0.9],...
'Color',[0.84 0.16 0]);
有关注释文本框属性的完整列表,请参见here.