Skip to content

Commit

Permalink
spmplot regenerated and redundant code inside typespm "number" rremoved
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoRianiUNIPR committed Jan 2, 2025
1 parent ba40892 commit 6cd7f7b
Show file tree
Hide file tree
Showing 20 changed files with 54 additions and 48 deletions.
87 changes: 45 additions & 42 deletions toolbox/graphics/spmplot.m
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@
% More precisely, typespm.lower controls how the part below
% the diagonal is shown and typespm.upper controls the upper
% part. Possible entries of typespm.lower or typespm.upper
% are "scatter", "circle", "square" "number" and "none";
% are "scatter", "circle", "square" "number" (number without
% color), "cnumber" (colored number) and "none".
% For example if typespm.lower="number" and
% typespm.upper="circle", the correlations in the part below
% the diagonal are shown with numbers and the upper part with
Expand Down Expand Up @@ -1026,6 +1027,17 @@
spmplot(mtcars,'typespm',typespm,'order','FPC');
%}

%{
%% Example of use of option order with cnumber.
% The order of the variables is based on the first
% eigenvector associated to the largest eigenvalue.
load mtcars
typespm=struct;
typespm.lower='circle';
% Number whose size and color depends on the corresponding rxy
typespm.upper='cnumber';
spmplot(mtcars,'typespm',typespm,'order','FPC');
%}

%% Beginning of code

Expand Down Expand Up @@ -1939,12 +1951,12 @@

elseif method=="number" || method== "cnumber" % method contains "number"

if lunigroup==1 % just one group (number of cnumber)
if lunigroup==1 % just one group (number of cnumber)
if method=="number"
% Show number without color
text(AX(i,j),0.5,0.5,num2str(R(i,j),2),'FontSize',Rresc(i,j), ...
'Units','normalized','HorizontalAlignment','center','Interpreter','Latex')
else
else % colored number
% Show number with color which depends on
% the value of R(i,j)
ind=find(index<=R(i,j),1,'last');
Expand All @@ -1963,7 +1975,7 @@
end
end

elseif method=="circle" || method =="square" || method =="number" %% TO DO remove here || method =="number"
elseif method=="circle" || method =="square"
% create new axes in position i,j
a=axes('Position',AX(i,j).Position);
a.XTick='';
Expand All @@ -1976,54 +1988,45 @@
pos = [center-radius 2*radius 2*radius];

if lunigroup==1
if method=="number"
text(0.5,0.5,num2str(R(i,j),2),'FontSize',Rresc(i,j), ...
'Units','normalized','HorizontalAlignment','center')
ind=find(index<=R(i,j),1,'last');
% rectangle('Position',pos, 'FaceColor', cmap(ind, :), 'EdgeColor', cmap(ind, :))
if method=="circle"
rectangle('Position',pos, 'Curvature',[1 1],'FaceColor', [cmap(ind, :) , abs(R(i,j))], 'EdgeColor', cmap(ind, :))
else
ind=find(index<=R(i,j),1,'last');
% rectangle('Position',pos, 'FaceColor', cmap(ind, :), 'EdgeColor', cmap(ind, :))
if method=="circle"
rectangle('Position',pos, 'Curvature',[1 1],'FaceColor', [cmap(ind, :) , abs(R(i,j))], 'EdgeColor', cmap(ind, :))
else
rectangle('Position',pos, 'FaceColor', [cmap(ind, :) , abs(R(i,j))], 'EdgeColor', cmap(ind, :))
end
rectangle('Position',pos, 'FaceColor', [cmap(ind, :) , abs(R(i,j))], 'EdgeColor', cmap(ind, :))
end
else
if method=="number"
text(0.2,0.5,num2str(R(i,j),2),'FontSize',Rresc(i,j), ...
'Units','normalized','HorizontalAlignment','center')
radius = max(abs(R(i,j)), 0.0001) * 3;
radius=radius/lunigroup;
center=[-2 0];
pos = [center-radius 2*radius 2*radius];
ind=find(index<=R(i,j),1,'last');
if method=="circle"
rectangle('Position',pos, 'Curvature',[1 1],'FaceColor', [cmap(ind, :) , abs(R(i,j))], 'EdgeColor', cmap(ind, :))
else
radius = max(abs(R(i,j)), 0.0001) * 3;
radius=radius/lunigroup;
center=[-2 0];
pos = [center-radius 2*radius 2*radius];
ind=find(index<=R(i,j),1,'last');
if method=="circle"
rectangle('Position',pos, 'Curvature',[1 1],'FaceColor', [cmap(ind, :) , abs(R(i,j))], 'EdgeColor', cmap(ind, :))
else
rectangle('Position',pos, 'FaceColor', [cmap(ind, :) , abs(R(i,j))], 'EdgeColor', cmap(ind, :))
end
rectangle('Position',pos, 'FaceColor', [cmap(ind, :) , abs(R(i,j))], 'EdgeColor', cmap(ind, :))
end

step=3/lunigroup;
center=[2 -3-step];
for jjj=1:lunigroup
if method=="number"
text(0.6,jjj/(lunigroup+1),num2str(Rgroup(i,j,jjj),2), ...
'Units','normalized','FontSize',Rgroupresc(i,j,jjj),'Color',clr(jjj))
step=3/lunigroup;
center=[2 -3-step];
for jjj=1:lunigroup
if method=="number"
text(0.6,jjj/(lunigroup+1),num2str(Rgroup(i,j,jjj),2), ...
'Units','normalized','FontSize',Rgroupresc(i,j,jjj),'Color',clr(jjj))

else
radius= max(abs(Rgroup(i,j,jjj)), 0.0001)* 3/lunigroup;
center(2)=center(2)+2*step;
pos = [center-radius 2*radius 2*radius];
ind=find(index<=Rgroup(i,j,jjj),1,'last');
if method=="circle"
rectangle('Position',pos, 'Curvature',[1 1],'FaceColor', [cmap(ind, :) , abs(Rgroup(i,j,jjj))] , 'EdgeColor', cmap(ind, :))
else
radius= max(abs(Rgroup(i,j,jjj)), 0.0001)* 3/lunigroup;
center(2)=center(2)+2*step;
pos = [center-radius 2*radius 2*radius];
ind=find(index<=Rgroup(i,j,jjj),1,'last');
if method=="circle"
rectangle('Position',pos, 'Curvature',[1 1],'FaceColor', [cmap(ind, :) , abs(Rgroup(i,j,jjj))] , 'EdgeColor', cmap(ind, :))
else
rectangle('Position',pos,'FaceColor', [cmap(ind, :) , abs(Rgroup(i,j,jjj))] , 'EdgeColor', cmap(ind, :))
end
rectangle('Position',pos,'FaceColor', [cmap(ind, :) , abs(Rgroup(i,j,jjj))] , 'EdgeColor', cmap(ind, :))
end
end
end

end

% axis equal is very slow: replaced
Expand Down
Binary file modified toolbox/helpfiles/FSDA/images/spmplot_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified toolbox/helpfiles/FSDA/images/spmplot_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified toolbox/helpfiles/FSDA/images/spmplot_03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified toolbox/helpfiles/FSDA/images/spmplot_04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified toolbox/helpfiles/FSDA/images/spmplot_05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified toolbox/helpfiles/FSDA/images/spmplot_06.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified toolbox/helpfiles/FSDA/images/spmplot_07.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified toolbox/helpfiles/FSDA/images/spmplot_08.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified toolbox/helpfiles/FSDA/images/spmplot_09.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified toolbox/helpfiles/FSDA/images/spmplot_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified toolbox/helpfiles/FSDA/images/spmplot_11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified toolbox/helpfiles/FSDA/images/spmplot_12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified toolbox/helpfiles/FSDA/images/spmplot_13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified toolbox/helpfiles/FSDA/images/spmplot_14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified toolbox/helpfiles/FSDA/images/spmplot_15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified toolbox/helpfiles/FSDA/images/spmplot_16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified toolbox/helpfiles/FSDA/images/spmplot_17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified toolbox/helpfiles/FSDA/images/spmplot_18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 9 additions & 6 deletions toolbox/helpfiles/FSDA/spmplot.html
Original file line number Diff line number Diff line change
Expand Up @@ -493,12 +493,14 @@

</p></p> <p class="description_valueexample"> <strong>Example: </strong><code> 'group',group
</code></p> <p class="datatypelist"><strong>Data Types: </strong><code>char</code></p></div></div><div class="expandableContent"><div id="inputarg_order" class="clearfix"></div><h3 id="input_argument_namevalue_order" class="expand"><span><a href="javascript:void(0);" style="display: block;" title="Expand/Collapse"><span class="argument_name"><code>order</code> &#8212;Order of the variables in the scatterplot matrix.</span></a><span class="example_desc">character | string.</span></span></h3><div class="collapse"> <p><p>Order in which the variables are shown inside
spmplot. Possible values are:
spmplot. Variable reordering can be used to improve the
visualization by placing similar variables next to each other.</p> <p>
Possible values are:
"alphabet"=alphabetical order is used;</p> <p>
"original"= the order in the input argument Y is preserved
(this is the default option);</p> <p>
"AOE" = the angular order of the first two eigenvectors is used.</p><p>
More precisely, the order of the variables is calculated from
"AOE" = the angular order of the first two eigenvectors is used.</p><p>
More precisely, the order of the variables is calculated from
the order of the angles, $a_i$:
</p>\[
a_i= tan^{-1}(e_{i1}/e_{i1}) \qquad \mbox{if} \qquad e_{i1}&gt;0;
Expand Down Expand Up @@ -645,15 +647,16 @@
More precisely, typespm.lower controls how the part below
the diagonal is shown and typespm.upper controls the upper
part. Possible entries of typespm.lower or typespm.upper
are "scatter", "circle", "square" "number" and "none";</p><p>
are "scatter", "circle", "square" "number" (number without
color), "cnumber" (colored number) and "none".</p><p>
For example if</p><table border="2" cellpadding="4" cellspacing="0" class="body"><colgroup><col width="20%"><col width="80%"></colgroup><thead><tr valign="top"><th valign="top">Value</th><th valign="top">Description</th></tr></thead><tr valign="top"><td><code>lower</code></td><td><p>"number" and</p></td></tr><tr valign="top"><td><code>upper</code></td><td><p>"circle", the correlations in the part below
the diagonal are shown with numbers and the upper part with
circles. Similarly, if typespm.lower="none" and</p></td></tr><tr valign="top"><td><code>scatter</code></td><td><p><p>"none" just the upper part of the scatter
plot matrix is shown. The fields of the struct can either
be characters or strings.</p> <p>
typespm='lower' is equivalent to typespm=struct;</p><p>
typespm.lower='scatter', typespm.upper='number';</p></p></td></tr></table></p> <p class="description_valueexample"> <strong>Example: </strong><code> 'typespm','lower'
</code></p> <p class="datatypelist"><strong>Data Types: </strong><code>char or struct</code></p></div></div><div class="expandableContent"><div id="inputarg_undock" class="clearfix"></div><h3 id="input_argument_namevalue_undock" class="expand"><span><a href="javascript:void(0);" style="display: block;" title="Expand/Collapse"><span class="argument_name"><code>undock</code> &#8212;Panel to undock and visualize separately.</span></a><span class="example_desc">matrix | logical matrix.</span></span></h3><div class="collapse"> <p><p>If undock='' (default), no panel is extracted. If
</code></p> <p class="datatypelist"><strong>Data Types: </strong><code>scalar char or string or alternatively a struct</code></p></div></div><div class="expandableContent"><div id="inputarg_undock" class="clearfix"></div><h3 id="input_argument_namevalue_undock" class="expand"><span><a href="javascript:void(0);" style="display: block;" title="Expand/Collapse"><span class="argument_name"><code>undock</code> &#8212;Panel to undock and visualize separately.</span></a><span class="example_desc">matrix | logical matrix.</span></span></h3><div class="collapse"> <p><p>If undock='' (default), no panel is extracted. If
undock is a r-by-2 matrix, it specifies the r coordinates
of the scatter plot matrix to undock and visualize
separately in a bivariate plot (i.e. for panels out of the
Expand Down Expand Up @@ -758,5 +761,5 @@


</p></p></div></div></div></div><div class="ref_sect" itemprop="content"><div class="bibliography"><h2 id="References">References</h2> <div><p>Friendly M. (2002), Corrgrams: Exploratory Displays for Correlation
Matrices. The American Statistician, v. 56, pp. 316–324,
Matrices. The American Statistician, v. 56, pp. 316–324,
<a href="https://doi.org/10.1198/000313002533">https://doi.org/10.1198/000313002533</a></p></div></div></div><div class="ref_sect"><h2 id="SeeAlso">See Also</h2><p><span itemprop="seealso"><a href="matlab:web(fullfile(docroot,'stats/gplotmatrix.html'))" itemprop="url"><span itemprop="name"><code>gplotmatrix</code></span></a></span> | <span itemprop="seealso"><a href="yXplot.html" itemprop="url"><span itemprop="name"><code>yXplot</code></span></a></span> | <span itemprop="seealso"><a href="boxplotb.html" itemprop="url"><span itemprop="name"><code>boxplotb</code></span></a></span></div><i>This page has been automatically generated by our routine <a href="publishFS.html">publishFS</a></i></div></section></div></div></div></div><div id="divbottom"></div></body></html>
Expand Down

0 comments on commit 6cd7f7b

Please sign in to comment.