小さなグラフのタイトルの設定
MATLAB®グラフィックスでは、タイトルに少し大きなフォントを太字で使用して見やすくしています。このため、Figure ウィンドウ内にテキストが収まらないことがあります。たとえば、次のコードは Figure ウィンドウに収まらない長いタイトルをもつグラフを作成します。
情节(1:10);title(['This is a title that is too long and does not fit',...'within the extents of the figure window.'])
タイトルのフォント サイズは、Axes のTitleFontSizeMultiplier
とFontSize
のプロパティに基づいています。既定では、FontSize
プロパティは 10 ポイントで、TitleFontSizeMultiplier
は1.100
です。つまり、タイトルのフォント サイズは 11 ポイントです。
座標軸の他のフォントに影響を与えずにタイトルのフォント サイズを変更するには、Axes のTitleFontSizeMultiplier
プロパティを設定します。
情节(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
プロパティを設定します。このプロパティを変更すると、タイトル、目盛りラベル、軸ラベルが存在する場合、これらのフォントが影響を受けます。
情节(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;
フォント サイズをそのままにしてタイトルを 2 行に表示するには、中かっこ{}
と共に cell 配列を使用して複数行のタイトルを定義します。
情节(1:10);标题({'This is a title that is too long and does not fit',...'within the extents of the figure window.'})