Scatter of large dataset indexing figure name
2 views (last 30 days)
Show older comments
Good evening everybody, I'm trying to analyze a dataset of 15 columns and more than 20000 rows. I need to obtain scatter plots of each column with all others to evaluate which columns are correlated. Example: column 1 must be plotted with columns 2,3,4,5,6,7,8,9,10,11,12,13,14,15; column 2 must be plotted with columns 3,4,5,6,7,..,15 and so on (note that I have considered relationship between columns 1 and 2 only once because of simmetry reasons and I'm neglecting each column with itself because it's trivial). I've tried with code below, but I've noted that not all combinations are plotted (figures with the same value of a are overwritten). Any suggestion to index figure names to avoid overwriting and obtain all combinations? Thank you for your support.
for q=1:1:15
for r=1:1:15
if q>r
a=nchoosek(q,r)
figure(a)
scatter(A_red{1,p}(:,q),A_red{1,p}(:,r))
xlabel(col_names1(q))
ylabel(col_names1(r))
end
end
end
0 Comments
Answers (2)
dpb
on 13 Feb 2021
Edited: dpb
on 13 Feb 2021
N=size(A,2);
for i=1:N
for j=i+1:N
figure
scatter(A(:,i),A(:,j))
xlabel(string(i))
ylabel(string(j))
end
end
You realize you'll end up with n!/r! (n-r)! figures this way I presume? If N = 15, that'll be
15!/2!/13! ==> 15*14/2 = 105 separate figures.
Would probably make more sense would be to compute R^2 for each and only plot those with significant values; you'd want those anyways.
r=tril(corr(A),-1);
r=r(r(:)~=0);
returns the vector of correlation coefficients in row order to match.
r=tril(corr(A),-1);
r=r(r(:)~=0);
RTHRESH=0.5;
N=size(A,2);
k=0;
for =1:N
for j=i+1:N
k=k+1;
if r(k)<RTHRESH, continue, end % skip those low-correlated
figure
scatter(A(:,i),A(:,j))
xlabel(string(i))
ylabel(string(j))
end
end
0 Comments
Walter Roberson
on 14 Feb 2021
for q=1:1:15
for r=1:1:15
if q>r
a=nchoosek(q,r)
figure(a)
hold on
scatter(A_red{1,p}(:,q),A_red{1,p}(:,r))
xlabel(col_names1(q))
ylabel(col_names1(r))
end
end
end
0 Comments
See Also
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!