Skip to content

Commit efbf19f

Browse files
committed
Tables: add correlation circles display
1 parent e0ddfa1 commit efbf19f

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
classdef PlotCorrelationCircles < imagem.actions.CurrentTableAction
2+
% Pair-wise scatter plot of table columns.
3+
%
4+
% Class PlotCorrelationCircles
5+
%
6+
% Example
7+
% PlotCorrelationCircles
8+
%
9+
% See also
10+
%
11+
12+
% ------
13+
% Author: David Legland
14+
15+
% Created: 2020-12-23, using Matlab 9.8.0.1323502 (R2020a)
16+
% Copyright 2020 INRAE - BIA-BIBS.
17+
18+
19+
%% Properties
20+
properties
21+
end % end properties
22+
23+
24+
%% Constructor
25+
methods
26+
function obj = PlotCorrelationCircles(varargin)
27+
% Constructor for PlotCorrelationCircles class.
28+
29+
end
30+
31+
end % end constructors
32+
33+
34+
%% Methods
35+
methods
36+
function run(obj, frame) %#ok<INUSL>
37+
38+
table = frame.Doc.Table;
39+
40+
% identify numeric columns
41+
inds = ~isFactor(table, 1:size(table, 2));
42+
colNames = table.ColNames(inds);
43+
44+
% Open a dialog for choosing the columns to display
45+
[numColInds, ok] = listdlg(...
46+
'ListString', colNames, ...
47+
'Name', 'Correlation Circles', ...
48+
'PromptString', 'Columns To Plot:', ...
49+
'ListSize', frame.Gui.Options.DlgListSize, ...
50+
'SelectionMode', 'Multiple');
51+
52+
if ~ok || isempty(numColInds)
53+
return;
54+
end
55+
56+
% create Plot Pair display
57+
createPlotFrame(frame.Gui);
58+
correlationCircles(table(:, numColInds));
59+
60+
% create pattern for writing history
61+
numColNames = table.ColNames(numColInds);
62+
nc = length(numColNames);
63+
pattern = ['{''%s''' repmat(', ''%s''', 1, nc-1) '}'];
64+
numColsString = sprintf(pattern, numColNames{:});
65+
66+
% add to history
67+
string = sprintf('figure; correlationCircles(%s(%s));\n', ...
68+
frame.Doc.Tag, numColsString);
69+
addToHistory(frame, string);
70+
71+
end
72+
end % end methods
73+
74+
end % end classdef
75+

ImageM/+imagem/+gui/FrameMenuBuilder.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ function buildTableFrameMenu(obj, hf)
395395
addMenuItem(obj, plotMenu, ScatterPlot(), 'Scatter Plot...', 'Separator', 'On');
396396
addMenuItem(obj, plotMenu, ScatterGroups(), 'Scatter Groups...');
397397
addMenuItem(obj, plotMenu, imagem.actions.table.plot.PairPlot(), 'Pair Plot...');
398+
addMenuItem(obj, plotMenu, PlotCorrelationCircles(), 'Correlation Circles...');
398399
addMenuItem(obj, plotMenu, PlotColumns(), 'Plot Columns...', 'Separator', 'on');
399400
addMenuItem(obj, plotMenu, PlotRows(), 'Plot Rows');
400401
addMenuItem(obj, plotMenu, ChoosePreferredPlotTypes(), 'Choose Preferred Plot Type...', 'Separator', 'on');

0 commit comments

Comments
 (0)