I have attached a fig file in which I have used 3 legends for upper, middle and lower curve, respectively. Actually, there are six lines in each curve but I want each curve to look like a single line. How is it possible using fig file.
1 回表示 (過去 30 日間)
古いコメントを表示
I have attached a fig file in which I have used 3 legends for upper, middle and lower curve, respectively. Actually, there are six lines in each curve but I want each curve to look like a single line. How is it possible using fig file.
0 件のコメント
採用された回答
Star Strider
2019 年 7 月 4 日
Try this:
I = openfig('comp25.fig');
Ax = gca;
lgnd = Ax.Legend;
Lines = findobj(Ax,'Type','line');
for k1 = 1:fix(numel(Lines)/6) % Consider 6 ‘Lines’ In Each Iteration
for k2 = 1:6
X(k2,:) = Lines(k2+(k1-1)*6).XData; % Get ‘X’ Values For This Set
Y(k2,:) = Lines(k2+(k1-1)*6).YData; % Get ‘Y’ Values For This Set
end
Xm(k1,:) = X(1,:); % X-Vector (For Plot)
Ym(k1,:) = mean(Y); % Y-Vector (For Plot) - Uses ‘mean’, ‘median’ Or Others May Be Appropriate As Well
end
figure
semilogy(Xm', Ym')
grid
legend(Ax.Legend.String)
xlabel(Ax.XLabel.String)
ylabel(Ax.YLabel.String)
It is difficult to determine what you want for each single line, so here I took th mean of each consecutive group of 6 Line objects.
2 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Legend についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!