フィルターのクリア

How to add title and x/y-labels after generating multiple figures?

8 ビュー (過去 30 日間)
Mattijs Mientki
Mattijs Mientki 2018 年 6 月 18 日
コメント済み: Mattijs Mientki 2018 年 6 月 18 日
x=[1 2 3] ;
y=[1 2 3; 1 3 9; 1 9 81];
for i = 1 : 3
f(i) = figure;
h(i) = plot(x,y(:,i))
end
%%what i want is something like this
f(i).xlabel('input Power [kW]')
f(i).xlabel('Energy of the system [kWh]')
This code shows shortly what I want. I generate in a loop a few figures, then afterwards to add the xlabel/ylabel and title. I can access the figure properties with f(i), but I could not find anywhere how to add the labels and the title.

採用された回答

Stephen23
Stephen23 2018 年 6 月 18 日
編集済み: Stephen23 2018 年 6 月 18 日
Your approach of obtaining and using explicit graphics handles is a good idea. However the axes title and axes labels are properties of the axes, not properties of the figure, so you will need to get the axes handle and use that. Note that plot returns handles/s to the line object/s, and the axes are the parent of the line object/s, so you could either:
  1. get the parent of the line objects, or
  2. create the axes explicitly and store their handle as well:
fgh(i) = figure();
axh(i) = axes(fgh(i));
lnh(i) = plot(axh(i),x,y(:,i));
  1 件のコメント
Mattijs Mientki
Mattijs Mientki 2018 年 6 月 18 日
Great, thank you! Also the image of the structure you send makes it more clear. I just have one question regarding do code you make. What does adding "axh(i)" to the plot function do?
plot(axh(i),x,y(:,i));

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by