MATLAB Answers

Plotting multiple ecdf in one plot with specific line color and width

169 ビュー (過去 30 日間)
Yaser Khojah
Yaser Khojah 2019 年 9 月 16 日
コメント済み: Yaser Khojah 2019 年 11 月 26 日
I'm plotting ecdf for a matrix where I want to chose the line color and type per column. I have this code but not sure how to change the color with the code.
figure
hold on
lgd = cell(size(NPV_Mat,2),1) ;
for ki = 1:size(NPV_Mat,2)
ecdf(NPV_Mat(:,ki));
lgd{ki} = strcat('Field=',num2str(ffield(ki))) ;
end
These are the color type as below:
color = ('b--o', 'c*', '-o', '*','--',':', '-','-.')
Any help please

  0 件のコメント

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

採用された回答

N S
N S 2019 年 11 月 25 日
It is necessary to capture the output of the Empirical cumulative distribution function so that you manage its rendering over a plot manually.
[f,x] = ecdf(y) returns the empirical cumulative distribution function (cdf), f, evaluated at the points in x, using the data in the vector y.
For example, for plotting in Red with line width of 3 and blacK using a line width of 2:
figure
hold on
[f1,x1]=ecdf(NPV_Mat1);
plot(x1,f1,'r','LineWidth',3)
[f2,x2]=ecdf(NPV_Mat2);
plot(x2,f2,'k','LineWidth',2)
hold off
Of course, you can use a for-loop to do it on a big number of variables.

  1 件のコメント

Yaser Khojah
Yaser Khojah 2019 年 11 月 26 日
Thanks a lot for your help. Much apperiated.

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

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by