SUBPLOT 関数を使用した際に Figure にタイトルをつける方法はありますか?

조회 수: 70 (최근 30일)
MathWorks Support Team
MathWorks Support Team 2013년 7월 8일
편집: MathWorks Support Team 2023년 4월 19일
SUBPLOT 関数を使用して、複数の Axes を表示させた場合に、 それら全体としてのタイトルを Figure につける方法を教えてください。

채택된 답변

MathWorks Support Team
MathWorks Support Team 2023년 3월 26일
편집: MathWorks Support Team 2023년 4월 19일
■R2018b 以降のバージョン
sgtitle 関数を使うことで、複数の subplot に対する全体のタイトルをつけることが可能です。
・sgtitle 関数
https://jp.mathworks.com/help/matlab/ref/sgtitle.html
■R2018a 以前のバージョン
直接的な機能はありません。
代替案として下記の 2 つの方法があります。
1. Figure 全体の Axes もしくはuipanel(パネル)を作成し、titleをつける方法
以下のコードでは、非表示の Axes を配置する方法です。
axes;
title('Master Title');
axis off;
また、下記 URL では、uipanel を使った例を紹介しています。
・MATLAB ドキュメンテーション:サブプロットのある Figure への上位タイトルの追加
https://jp.mathworks.com/help/matlab/creating_plots/combine-multiple-plots.html#d120e2827
2. textラベルを使用する方法
textラベルを使用すると、以下のコードで Figure にタイトルをつけられます。以下のコードは、 SUBTITLE.m として保存して関数として使用できます。
function [ax,h]=subtitle(text)
%
%Centers a title over a group of subplots.
%Returns a handle to the title and the handle to an axis.
% [ax,h]=subtitle(text)
% returns handles to both the axis and the title.
% ax=subtitle(text)
% returns a handle to the axis only.
ax=axes('Units','Normal','Position',[.075 .075 .85 .85],'Visible','off');
set(get(ax,'Title'),'Visible','on')
title(text);
if (nargout < 2)
return
end
h=get(ax,'Title');
 
また、ご参考までに、MATLAB のユーザコミュニティである MATLAB Central に SUBPLOT を使用した際にも Figure 全体のタイトルをつけるプログラムがあります。
・mtit: a pedestrian major title creator
なお、MATLAB Centralにおいてフリーで公開されているファイルの内容に関しましては、直接プログラム作成者の方にお問い合わせください。

추가 답변 (0개)

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!