Hi! I want to report in a graph the variances explained as a function of PCs as shown in the graph. I have used the function "pareto(ExplVar)" but only the first 10 are represented and not all (there are 20 PCs in total). How can I represent them all?

댓글 수: 2

Anmol Dhiman
Anmol Dhiman 2021년 1월 13일
Hi Alberto ,
Could you share your code for better resolution of the issue
The code is long. I have considered
p = pareto(ExplVar)
where ExplVar is an array 10000x1.

댓글을 달려면 로그인하십시오.

 채택된 답변

Ive J
Ive J 2021년 1월 13일
편집: Ive J 2021년 1월 13일

1 개 추천

pareto only shows the first 10 bars at maximum. You can do it easily with help of cumsum:
[~, ~, ~, ~, explained] = pca(rand(100,20));
hold on
bar(explained)
plot(1:numel(explained), cumsum(explained), 'o-', 'MarkerFaceColor', 'r')
yyaxis right
h = gca;
h.YAxis(2).Limits = [0 100];
h.YAxis(2).Color = h.YAxis(1).Color;
h.YAxis(2).TickLabel = strcat(h.YAxis(2).TickLabel, '%');

댓글 수: 4

Alberto Acri
Alberto Acri 2021년 1월 13일
thanks, but I obtained the PCs through the pareto function and I can't apply what you told me to my case.
Ive J
Ive J 2021년 1월 13일
편집: Ive J 2021년 1월 13일
What do you mean you obtained PCs through the pareto function?! Pareto charts display the values in the vector Y as bars drawn in descending order. Values in Y must be nonnegative and not include NaNs. Only the first 95% of the cumulative distribution is displayed. So how did you obtain your PCs through pareto?!
As you mentioned above you use it as
pareto(ExplVar)
Whatever ExplVar is (either PC scores themselves or explained variances) this example does similar to what pareto does.
In this
[~, ~, ~, ~, explained] = pca(rand(100,20))
Should I introduce the PCs I found?
Ive J
Ive J 2021년 1월 15일
If you are calculating PCs with MATLAB pca built-in function, it can also return explained variances of PCs (explained in above example). If you want to show these explained variances (cumulatively), use explained; otherwise use PC scores if you prefer. It depends on your purposes of course (even you can use anything else to plot), but regardless, you can use my above example to reproduce similar graphs as pareto does, but without it's limitations (i.e. max 10 bars).

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Descriptive Statistics and Visualization에 대해 자세히 알아보기

제품

릴리스

R2020a

질문:

2021년 1월 10일

댓글:

2021년 1월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by