How could I graph the percent of variance by PC component?

3 views (last 30 days)
I am trying to replicate these graphs with my own data but the pca function doesn't give this graphs explicitly. Do I have to extract these numbers from the code and plot them elsewhere? (explained vs. pc) If so, would I just plot explained vs. pc (is that the simplest way to do it? anD THE SIMPLEST WAY TO plot the scores vs. each pC? I am sure there's a quick fix but I wanted to make sure i had different options. Thanks

Accepted Answer

the cyclist
the cyclist on 18 Feb 2023
You are correct that the pca function does not have an option to plot directly, and you do need to take the output and then plot it.
You are also correct that to get a scree plot like the one you attached, the easiest way is just plot the explained output from pca.
To get the other graph, that you included as an image, you probably want to use the histogram function on the score output. If you want three sets of axes in one figure, as shown, then I'd suggest the tiledlayout function.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!