Hello,
I would like to repeat the same plot many set of data in several figures but with varying Y limits, eg:
figure(1);
p1=errorbar(X, Y1, Z1,'-ob','MarkerSize',4);hold on
p2=....
pN=errorbar(X, YN, ZN,'-og','MarkerSize',4);
legend([p1 p2 ....pN], '1', '2', .....'N');
ylim([0,1]);
%
figure(2);
% The same as in Figure 1 but with, for example,
ylim([0,0.1]);
Since I have to plot many figures using several ylim, I wonder whether there is an automatic way to plot figure(2) by recalling p1...pN without rewriting the N lines of Figure(1).
Thank you for your help
Ferdinando

 採用された回答

Geoff Hayes
Geoff Hayes 2020 年 4 月 15 日

0 投票

Ferdinando - if you create a cell array of all of the different y-axis limits, then you could just iterate over that array, creating a new figure each time
yaxisLimits = {[0 1], [0 0.1]};
for k = 1:length(yaxisLimits)
figure(k);
p1=errorbar(X, Y1, Z1,'-ob','MarkerSize',4);hold on
% p2=....
pN=errorbar(X, YN, ZN,'-og','MarkerSize',4);
legend([p1 p2 ....pN], '1', '2', .....'N');
ylim(yaxisLimits{k});
end

1 件のコメント

Ferdinando Formisano
Ferdinando Formisano 2020 年 4 月 15 日
It works fine, thank you very much Geoff

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

製品

リリース

R2017b

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by