Scatter of large dataset indexing figure name
조회 수: 4 (최근 30일)
이전 댓글 표시
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
답변 (2개)
dpb
2021년 2월 13일
편집: dpb
2021년 2월 13일
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
Walter Roberson
2021년 2월 14일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Scatter Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!