forked from ilarinieminen/SOM-Toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
som_show_clear.m
142 lines (128 loc) · 4.83 KB
/
som_show_clear.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
function som_show_clear(type, p)
%SOM_SHOW_CLEAR Clear hit marks, labels or trajectories from current figure.
%
% som_show_clear([type], [p])
%
% som_show_clear
% som_show_clear('Traj',[1 2])
%
% Input arguments ([]'s are optional):
% [type] (string) which markers to delete (case insensitive)
% 'hit' to remove hit marks
% 'lab' to remove labels
% 'traj' to remove line trajectories
% 'comet' to remove comet trajectories
% 'all' to remove all (the default)
% [p] (vector) subplot number vector
% (string) 'all' for all subplots (the default)
%
% This function removes the objects made by SOM_SHOW_ADD from a
% figure. If no value is given for p, the function operates on every
% axis in the current figure. It simply searches for the objects with
% certain values in the 'Tag' field. It does not matter if the figure
% objects are created by SOM Toolbox -functions or not. However, if
% vector p or string 'all' _is_ given, the figure has to have been
% created by SOM_SHOW.
%
% For more help, try 'type som_show_clear' or check out the helpdesk.
% See also SOM_SHOW_ADD, SOM_SHOW.
%%%%%%%%% DETAILED DESCRIPTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% som_show_clear
%
% PURPOSE
%
% Clear hit marks, labels or trajectories created by SOM_SHOW_ADD
% from the current figure.
%
% SYNTAX
%
% som_show_clear
% som_show_clear([type],[p])
%
% DESCRIPTION
%
% The function SOM_SHOW_ADD creates some markers on the top of
% visualizations made by SOM_SHOW. These objects may be removed using
% SOM_SHOW_CLEAR even if the object handles are not known. The function
% removes the objects based on certain tags written to the 'Tag' property
% field of the objects.
%
% If the function if called without input arguments it searches for
% every object in the current figure that have string
% 'Hit','Lab','Traj' or 'Comet' in their Tag property field and
% deletes them.
%
% If input argument p is not specified, the function does not check that the
% figure is created by function SOM_SHOW.
%
% OPTIONAL INPUT ARGUMENTS
%
% type (string) Which type of markers to delete
% 'Hit' for removing hit marks
% 'Lab' labels
% 'Traj' line trajectories
% 'Comet' comet trajectories
% 'All' all (the default)
% Strings are case insensitive.
%
% p (vector) Subplots from which the markers are removed
% Specifies the subplots from which the markers are removed.
% The valid values are 1...N where N is the number of subplots.
% It is required that the figure has been created by
% the SOM_SHOW function.
%
% EXAMPLES
%
% som_show_clear;
% % deletes all labels, hit marks and trajectories in the figure
% som_show_clear('hit');
% % deletes all the hit marks in the current figure
% som_show_clear('lab',[1 2]);
% % deletes labels in SOM_SHOW figure subplots 1 and 2.
%
% SEE ALSO
%
% som_show Basic map visualizations: component planes, u-matrix etc.
% som_show_add Show hits, labels and trajectories on SOM_SHOW visualization.
% Copyright (c) 1997-2000 by the SOM toolbox programming team.
% http://www.cis.hut.fi/projects/somtoolbox/
% Version 1.0beta Johan 061197
% Version 2.0beta Johan 061099 juuso 181199
%%% Check number of arguments
error(nargchk(0,2, nargin)) % check no. of input args is correct
%%% Initialize & check & action %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if nargin == 0 || isempty(type) || strcmp(type,'all') % delete everything
% in the gcf
delete(findobj(gcf,'Tag','Hit'));
delete(findobj(gcf, 'Tag','Lab'));
delete(findobj(gcf, 'Tag','Traj'));
delete(findobj(gcf, 'Tag','Comet'));
return
end
if nargin < 2 || isempty(p) % check handles
handle=gcf;
else % check subplot handles if p is given
[handle,msg]=vis_som_show_data(p,gcf);
if ~isempty(msg)
error('2nd argument invalid or figure not made by SOM_SHOW: try SOM_SHOW_CLEAR without arguments.');
end
end
switch lower(type) % check type & make proper tag names
case 'hit'
tag = 'Hit';
case 'lab'
tag = 'Lab';
case 'traj'
tag = 'Traj';
case 'comet'
tag = 'Comet';
otherwise
error('Invalid object tag. Must be {lab | hit | traj | comet}');
end
%%% Action %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:length(handle),
h=findobj(handle(i),'Tag',tag); % find object handles
delete(h); % delete objects
end
%%% No output %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%