メインコンテンツ

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

小さなグラフのタイトルの設定

MATLAB® グラフィックスでは、タイトルに少し大きなフォントを太字で使用して見やすくしています。このため、長いタイトルは Figure ウィンドウ内に収まらないことがあります。たとえば、次のコードは Figure ウィンドウに収まらない長いタイトルをもつプロットを作成します。

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

Plot with a title that does not fit within the extents of the figure window

タイトルのフォント サイズは、Axes の TitleFontSizeMultiplierFontSize のプロパティに基づいています。既定では、FontSize プロパティは 10 ポイントで、TitleFontSizeMultiplier1.100 です。つまり、タイトルのフォント サイズは 11 ポイントです。

座標軸の他のテキストに影響を与えずにタイトルのフォント サイズを変更するには、Axes の 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;

Plot with a title whose font is the same size as other text in the axes

座標軸全体でフォント サイズを小さくするには、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 with all fonts set to eight-point size

タイトルを 2 行に表示するには、中かっこ {} と共に cell 配列を使用して複数行のタイトルを定義します。

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

Plot with a title that is displayed across two lines

参考

関数

プロパティ