フィルターのクリア

Apply hold on to multiple figures in a loop

28 ビュー (過去 30 日間)
mael thevenot
mael thevenot 2019 年 8 月 29 日
コメント済み: mael thevenot 2019 年 8 月 29 日
Hi,
I'm currently using a script creating a figure and using "hold on".
Then inside a for loop i'm adding a lot of curves to this figure and I have a "hold off" after the loop.
This is working fine, but right now I would like to reproduce the same thing and having 4 different figures (and not having to copy 4 times the same for loop...). So for example at the beginning of the script I create my 4 figures
a = figure(1)
b = figure(2)
c = figure(3)
d = figure(4)
Then I have my for loop to add at each loop a curve inside of the figure a, b, c or d depending on some condition.
But the problem is it's working fine with one figure but with multiple figures I can't figure out (haha) how to apply the "hold on" to each figure during the loop?
I didn't find a solution online, do someone know how to hold multiple figures at the same time?
Thanks

採用された回答

Stephen23
Stephen23 2019 年 8 月 29 日
編集済み: Stephen23 2019 年 8 月 29 日
"how to apply the "hold on" to each figure"
The properties affected by hold are all axes properties, which have nothing to do with figures. When you read the hold documentation it optionally allows an axes handle to be specified (not a figure handle, which hold has nothing to do with).
It is trivial to use a loop and indexing to access graphics handles, e.g.:
for k = 1:4
fh(k) = figure(k);
ax(k) = axes('parent',fh(k));
...
hold(ax(k),'on')
...
end
  1 件のコメント
mael thevenot
mael thevenot 2019 年 8 月 29 日
It worked perfectly, thank you very much! :)

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by