Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

缩小图形标题

MATLAB® 图形标题使用加粗的微大字体,以便更醒目。因此,一些文本可能在图窗窗口中无法容纳。例如,此代码创建一个图形,其中的长标题无法容纳在图窗窗口范围内。

plot(1:10);
title(['This is a title that is too long and does not fit',...
    'within the extents of the figure window.'])

标题字体大小取决于坐标区的 TitleFontSizeMultiplierFontSize 属性。默认情况下,FontSize 属性为 10 磅,而 TitleFontSizeMultiplier1.100,这意味着标题字体大小为 11 磅。

若要更改标题字体大小而不影响坐标区的其他部分字体,请设置坐标区的 TitleFontSizeMultiplier 属性。

plot(1:10);
title(['This is a title that is too long and does not fit',...
    'within the extents of the figure window.'])
ax = gca;
ax.TitleFontSizeMultiplier = 1;

若要使整个坐标区的字体变小,请设置 FontSize 属性。更改此属性会影响标题、刻度标签和坐标轴标签(如果存在)的字体。

plot(1:10);
title(['This is a title that is too long and does not fit',...
    'within the extents of the figure window.'])
ax = gca;
ax.FontSize = 8;

若要保持字体大小相同并跨行显示标题,请使用带有花括号 {} 的元胞数组定义多行标题。

plot(1:10);
title({'This is a title that is too long and does not fit',...
    'within the extents of the figure window.'})

另请参阅

函数

属性