Skip to content

Commit 845a70a

Browse files
committed
add Histogram of Table column
1 parent e19f3e6 commit 845a70a

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
classdef PlotColumnHistogram < imagem.actions.CurrentTableAction
2+
% Histogram of the values within the selected column of a table.
3+
%
4+
% Class PlotColumnHistogram
5+
%
6+
% Example
7+
% PlotColumnHistogram
8+
%
9+
% See also
10+
%
11+
12+
% ------
13+
% Author: David Legland
14+
15+
% Created: 2020-12-07, 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 = PlotColumnHistogram(varargin)
27+
% Constructor for PlotColumnHistogram class.
28+
29+
end
30+
31+
end % end constructors
32+
33+
34+
%% Methods
35+
methods
36+
function run(obj, frame) %#ok<INUSL>
37+
38+
% retrieve data
39+
gui = frame.Gui;
40+
table = frame.Doc.Table;
41+
42+
% create a dialog to select column from its name
43+
[indVar, ok] = listdlg('ListString', table.ColNames, ...
44+
'Name', 'Histogram', ...
45+
'PromptString', 'Column to display:', ...
46+
'ListSize', gui.Options.DlgListSize, ...
47+
'SelectionMode', 'single');
48+
49+
% check the click on the "OK" button
50+
if ~ok || isempty(indVar)
51+
return;
52+
end
53+
54+
% prepare graphics
55+
createPlotFrame(gui);
56+
57+
% plot the histogram
58+
histogram(table(:, indVar));
59+
end
60+
61+
end % end methods
62+
63+
end % end classdef
64+

ImageM/+imagem/+gui/FrameMenuBuilder.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ function buildTableFrameMenu(obj, hf)
388388

389389
% Plot menu
390390
plotMenu = addMenu(obj, hf, 'Plot');
391-
addMenuItem(obj, plotMenu, ScatterPlot(), 'Scatter Plot...');
391+
addMenuItem(obj, plotMenu, PlotColumnHistogram(), 'Histogram...');
392+
addMenuItem(obj, plotMenu, ScatterPlot(), 'Scatter Plot...', 'Separator', 'On');
392393
addMenuItem(obj, plotMenu, ScatterGroups(), 'Scatter Groups...');
393394
addMenuItem(obj, plotMenu, BoxPlot(), 'Box Plot...', 'Separator', 'on');
394395
addMenuItem(obj, plotMenu, GroupBoxPlot(), 'Box Plot by Group...');

0 commit comments

Comments
 (0)