Clear Filters
Clear Filters

Plot projection points after PCA analysis

2 views (last 30 days)
I have these simple points:
X = [-0.7142;-1.7142;-1.7142;-0.7142;1.2857;1.2857;2.2857];
Y = [1.2857;0.2857;-0.7142;0.2857;0.2857;-0.7142;-0.7142];
I then found the projected points (using PCA) as
X_proj = [-2.2316; 0.0648; 1.044; -0.2725; -2.1535; 1.7647; 1.2005];
Y_proj = [2.8746; 3.4734; 1.5356; 1.5142; -2.4040; -1.4030; -2.3826];
I found the PCA axis as:
y1 = 0.2053*x1 + 0;
y2 = -0.48719*x2 + 0;
How can I show these points graphically on the two different planes?
Thanks.
  1 Comment
monkey_matlab
monkey_matlab on 22 Oct 2016
Hello, How do I go about showing the original points and then the projected points on two different planes? Although the attached image is a little degraded, there are two planes:
Do I have to use a 3D plot then?

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 22 Oct 2016
(Regarding the image you added to clarify the post...) Why do you want them on different planes? Personally I think having two different marker shapes is fine. You could even give them different colors if you want. But I think plotting in 3D would just unnecessarily complicate it. But if you insist, you can do it with plot3()
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
%clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format short g;
format compact;
fontSize = 20;
x1 = 4*rand(1, 6) - 2;
y1 = 4*rand(1, 6) - 2;
x2 = 4*rand(1, 6) - 2;
y2 = 4*rand(1, 6) - 2;
% Plot set 1 as red * at plane z=0
z1 = zeros(1, length(x1));
plot3(x1, y1, z1, 'r*', 'MarkerSize', 8, 'LineWidth', 2);
% Plot set 2 as blue circles at plane z=1.5
z2 = 1.5 * ones(1, length(x2));
hold on; % Don't blow away set #1!
plot3(x2, y2, z2, 'bo', 'MarkerSize', 8, 'LineWidth', 2);
grid on;
xlabel('X', 'FontSize', fontSize);
ylabel('Y', 'FontSize', fontSize);
zlabel('Z', 'FontSize', fontSize);

More Answers (1)

Image Analyst
Image Analyst on 22 Oct 2016
What is wrong with plot()?

Categories

Find more on Dimensionality Reduction and Feature Extraction in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!