% Plot stock data with factor loads as coordinates

load stockreturns

[loadspm,spvarpm] = factoran(stocks,3,'rotate','promax');

subplot(1,2,1); 
plot(loadspm(:,1),loadspm(:,2),'b.');
text(loadspm(:,1),loadspm(:,2), num2str((1:10)')); 
line([-1 1 NaN 0 0 NaN 0 0],[0 0 NaN -1 1 NaN 0 0],'Color','black');
xlabel('Factor 1'); 
ylabel('Factor 2'); 
axis square;

subplot(1,2,2); 
plot(loadspm(:,1),loadspm(:,3),'b.');
text(loadspm(:,1),loadspm(:,3), num2str((1:10)')); 
line([-1 1 NaN 0 0 NaN 0 0],[0 0 NaN -1 1 NaN 0 0],...
     'Color', 'black');
xlabel('Factor 1');
ylabel('Factor 3');
axis square;