?? som_show_add.m
字號:
%% Not yet ready%% SEE ALSO% % som_show Basic map visualization% som_show_clear Clear hit marks, labels or trajectories from current figure. % Copyright (c) 1999-2000 by the SOM toolbox programming team.% http://www.cis.hut.fi/projects/somtoolbox/ % Version 2.0beta Johan 131199%% Check arguments %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%error(nargchk(2,Inf,nargin)) % check no. of input args% Get data from the SOM_SHOW figure, exit if error[handles,msg,lattice,msize,dim]=vis_som_show_data('all',gcf); error(msg); munits=prod(msize);% Initialize some variables: these must exist later; % the default values are set by subfunctionsProperty=init_properties;Property.handles=handles; %%% Check mode and that D is of right type & size for that mode % mode has to be stringif ~vis_valuetype(mode,{'string'}), error('String value expected for first input argument (mode).');else mode=lower(mode); % case insensitive mode_=mode; % 'mode' is internal variable; % for program constructs 'mode_' is shown to % user in some error messagsendswitch mode % check mode case 'hit' %%% Hit histogram visualization: vector [msize k] if ~vis_valuetype(D,{'nxm'}), error('Hit visualization: a matrix expected for data input.'); elseif size(D,1) ~= prod(msize) error('Hit visualization: data and map size do not match.'); end % Multiple hit histograms if size(D,2)>1 mode='mhit'; % Hit count musn't be negative if any(D(:)<0), error('Hit visualization: negative hit count in data not allowed!'); end end case {'traj','comet'} %%% Trajectory like visualizations if ~vis_valuetype(D,{'nx1'}), error('Trajectory/Comet: a Nx1 vector expected for data input.'); elseif any(D>prod(msize))| any(D<1), error('Trajectory/Comet: BMU indices out of range in data input.'); elseif any(fix(D)~=D), warning('Trajectory/Comet: BMU indices not integer. Rounding...'); elseif size(D,1)<2 error('At least two BMU indexes expected.'); end case 'label' %%% Label visualizations if isstruct(D), % check if D is a map [tmp,ok,tmp]=som_set(D); if all(ok) & strcmp(D.type,'som_map') ; else error('Map struct is invalid!'); end % Size check if length(msize) ~= length(D.topol.msize) | ... munits ~= prod(D.topol.msize), error(['The size of the input map and the map in the figure' ... ' do not match.']); end D=D.labels; % Cell input elseif vis_valuetype(D,{'2Dcellarray_of_char'}) ; % Char input elseif vis_valuetype(D,{'char_array'}), D=cellstr(D); else error(['Labels has to be in a map struct or in a cell array' ... ' of strings']); end if size(D,1) ~= munits error(['The number of labels does not match the size of the map' ... ' in the figure.']); end otherwise error('Invalid visualization mode.');end if rem(length(varargin),2) error('Mismatch in identifier-value pairs or wrong input argument order.');end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% read in optional argumentsfor i=1:2:length(varargin), %% Check that all argument types are strings if ~ischar(varargin{i}) error('Invalid identifier name or input argument order.'); end %% Lower/uppercase in identifier types doesn't matter: identifier=lower(varargin{i}); % identifier (lowercase) value=varargin{i+1}; % Check property identifiers and values and store the values. % Struct used_in is set to initiate warning messages: % if a don't care propersty is set, the user is warned. switch identifier case 'marker' %%% Marker for hits or trajectories switch mode case 'mhit' if vis_valuetype(value,{'markerstyle'}) | ... (vis_valuetype(value,{'string'}) & ... any(strcmp(value,{'lattice','pie'}))), ; % ok elseif vis_valuetype(value,{'cellcolumn_of_char'}), if size(value,1) ~= size(D,2) error([' If a cell of Markers is specified its size must be' ... ' number_of_hit_histograms x 1.']); else for i=1:size(D,2), if ~vis_valuetype(value{i},{'markerstyle'}) error('Cell input for ''Marker'' contains invalid styles.') end end end else error([' Invalid ''Marker'' in case of multiple hit histograms.' ... char(10) ' See detailed documentation.']) end case {'comet','hit'} if vis_valuetype(value,{'markerstyle'}) | isempty(value), % ok; elseif ischar(value) & strcmp(value,'lattice'), % ok; else error(['Marker must be Matlab''s marker style, or string' ... ' ''lattice''.']); end case 'traj' if ~vis_valuetype(value,{'markerstyle'}) & ~isempty(value), error('In mode ''traj'' Marker must be one of Matlab''s built-in marker styles'); end end used_in.comet=1; % Set relevance flags used_in.traj=1; used_in.label=0; used_in.hit=1; used_in.mhit=1; case 'markersize' %%% Marker for hits or trajectories switch mode case 'comet' if ~vis_valuetype(value,{'1x2'}) & ~isempty(value), error('In mode ''comet'' MarkerSize'' must be a 1x2 vector.'); end case {'hit','traj'} if ~vis_valuetype(value,{'1x1'}) & ~isempty(value), error(['In mode ''' mode_ ... ''' ''MarkerSize'' must be a scalar.']); end end used_in.comet=1; % Set relevance flags used_in.traj=1; used_in.label=0; used_in.hit=1; used_in.mhit=1; case 'sizefactor' %%% Hit dependent size factor switch mode case 'traj' if ~vis_valuetype(value,{'string'}) | ... ~any(strcmp(value,{'hit', 'equal'})), error(['In mode ''traj'' ''SizeFactor'' must be ' ... 'string ''equal'' or ''hit''.']); end case 'mhit' if ~vis_valuetype(value,{'string'}) | ... ~any(strcmp(value,{'common', 'separate'})), error(['In mode ''hit'' ''SizeFactor'' must be ' ... 'string ''common'' or ''separate''.']); end end used_in.comet=0; % Set relevance flags used_in.traj=1; used_in.label=0; used_in.hit=0; used_in.mhit=1; case 'markercolor' %%% Markercolor switch mode case 'comet' if ~vis_valuetype(value,{'colorstyle','1x3rgb'}) & ... ~vis_valuetype(value,{'nx3rgb',[size(D,1) 3]},'all') & ... ~isempty(value), error(['MarkerColor in mode ''comet'' must be a ColorSpec,' ... ' string ''none'' or Mx3 matrix of RGB triples.']); end case 'mhit' if ~vis_valuetype(value,{[size(D,2) 3],'nx3rgb'},'all') & ... ~vis_valuetype(value,{'colorstyle','1x3rgb'}), error([' If multiple hit histograms in mode ''hit'' are' ... char(10) ... ' given MarkerColor must be ColorSpec or a Kx3 matrix' ... char(10)... ' of RGB triples where K is the number of histograms.']); end case 'hit' if ~vis_valuetype(value,{'colorstyle','1x3rgb'}) & ... ~isempty(value), error(['MarkerColor in mode ''hit'' ' ... 'must be a ColorSpec or string ''none''.']); end case 'traj' if ~vis_valuetype(value,{'colorstyle','1x3rgb'}) & ... ~isempty(value), error(['MarkerColor in mode ''traj'' ' ... 'must be a ColorSpec or string ''none''.']); end end used_in.comet=1; % Set relevance flags used_in.traj=1; used_in.label=0; used_in.hit=1; used_in.mhit=1; case 'edgecolor' %%% Color for marker edges if ~vis_valuetype(value,{'colorstyle','1x3rgb'}) & ~isempty(value), error('''EdgeColor'' must be a ColorSpec or string ''none''.') end used_in.comet=1; % Set relevance flags used_in.traj=1; used_in.label=0; used_in.hit=1; used_in.mhit=1; case 'text' %%% Labeling for trajectories/hits switch mode case 'hit' %%% Hit count using numbers? if isempty(value), value='off'; elseif vis_valuetype(value,{'string'}) & ... ~any(strcmp(value,{'on','off'})), error('Value for Text in mode ''hit'' should be ''on'' or ''off''.'); else ; % ok end %case 'traj','comet' % if ~vis_valuetype(value,{'char_array','cellcolumn_of_char'}) & ... % ~isempty(value) % error('Value for Text is of wrong type or size.') % elseif ischar(value) % value=strcell(value) % ok, convert to cell % end % if size(traj_label,1)~=size(D,1) % error(['The number of labels in Text and the length of the' ... % ' trajectory do not match.']); % end case 'label' ; % not used end used_in.comet=0; % Set relevance flags used_in.traj=0; used_in.label=0; used_in.hit=1; used_in.mhit=0; case 'textsize' %%% Text size for labels if ~vis_valuetype(value,{'1x1'}) & ~isempty(value), error('TextSize must be scalar.'); end used_in.comet=0; % Set relevance flags used_in.traj=0; used_in.label=1; used_in.hit=1; used_in.mhit=0; case 'textcolor' %%% Color for labels if ~vis_valuetype(value,{'colorstyle','1x3rgb','xor'}) & ~isempty(value), error('''TextColor'' must be ColorSpec, ''xor'' or ''none''.') end used_in.comet=0; % Set relevance flags used_in.traj=0; used_in.label=1; used_in.hit=1; used_in.mhit=0; case 'trajwidth' %%% Basic line width for a line trajectory if ~vis_valuetype(value,{'1x1'}) & ~isempty(value), error('TrajWidth must be a scalar.'); end used_in.comet=0; % Set relevance flags used_in.traj=1; used_in.label=0; used_in.hit=0; used_in.mhit=0; case 'widthfactor' %%% Hit factor for a line trajectory if ~vis_valuetype(value,{'string'}) | ... ~any(strcmp(value,{'hit', 'equal'})), error(['In mode ''traj'' ''WidthFactor'' must be ' ... 'string ''equal'' or ''hit''.']); end used_in.comet=0; % Set relevance flags used_in.traj=1; used_in.label=0; used_in.hit=0; used_in.mhit=0; case 'trajcolor' %%% Color for trajectory line if ~vis_valuetype(value,{'colorstyle','1x3rgb','xor'}) & ~isempty(value), error('''TrajColor'' must be a ColorSpec or string ''xor''.') end used_in.comet=0; % Set relevance flags used_in.traj=1; used_in.label=0; used_in.hit=0; used_in.mhit=0; case 'uselabel' %%% Which labels to show error('Not yet implemented.'); case 'shift' if ~vis_valuetype(value,{'1x1'}) | ((value < 0) | (value > 1)), error('''Shift'' must be a scalar in range [0,1].') end used_in.comet=0; % Set relevance flags used_in.traj=0; used_in.label=0; used_in.hit=0; used_in.mhit=1; case 'subplot' %%% The subplots which are affected if vis_valuetype(value,{'1xn','nx1','string'}), if ischar(value), if ~strcmp(value,'all'), error('Only valid string value for subplot indices is ''all''.'); else value=1:length(handles); end elseif any(value<1) | any(value>length(handles)), error('Subplot indices must be in range 1...number_of_subplots!'); end elseif ~isempty(value) error('Invalid subplot indices!'); end used_in.comet=1; % Set relevance flags used_in.traj=1; used_in.label=1; used_in.hit=1; used_in.mhit=1; otherwise error([ 'Unknown identifier ''' identifier '''.']); end % Warn user if the property that was set has no effect in the % selected visuzlization mode if ~getfield(used_in, mode), warning(['Property ''' identifier ''' has no effect in mode ''' ...
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -