Borrar filtros
Borrar filtros

Scatter of large dataset indexing figure name

4 visualizaciones (últimos 30 días)
Antonio Tricarico
Antonio Tricarico el 13 de Feb. de 2021
Respondida: Walter Roberson el 14 de Feb. de 2021
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

Respuestas (2)

dpb
dpb el 13 de Feb. de 2021
Editada: dpb el 13 de Feb. de 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

Walter Roberson
Walter Roberson el 14 de Feb. de 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

Categorías

Más información sobre Scatter Plots en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by