SUBPLOT 関数を使用した際に Figure にタイトルをつける方法はありますか?
51 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 8 Jul. 2013
Bearbeitet: MathWorks Support Team
am 19 Apr. 2023
SUBPLOT 関数を使用して、複数の Axes を表示させた場合に、 それら全体としてのタイトルを Figure につける方法を教えてください。
Akzeptierte Antwort
MathWorks Support Team
am 26 Mär. 2023
Bearbeitet: MathWorks Support Team
am 19 Apr. 2023
■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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Subplots finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!