?? som_show_add.m
字號(hào):
% Set axis axes(handles(p(i))); % Get hold state and caxis memhold=ishold; cax=caxis; hold on; switch mode case 'lattice' h_(i,1)=som_cplane(lattice, coord, color, spotSize*Property.markersize); case 'marker' [S,m]=som_grid(lattice, [N 1],... 'Coord',coord, ... 'Line','none',... 'Marker',marker,... 'MarkerColor',color,... 'MarkerSize', spotSize*Property.markersize); h_=[h_;m(:)]; case 'pie' h_(i)=som_pieplane(lattice, coord, ... Hits, Property.markercolor, ... totHits*Property.markersize); end % Restore hold state and caxis if ~memhold hold off; end caxis(cax);end% Set edgecolorif any(strcmp(mode,{'lattice','pie'})), set(h_,'edgecolor',Property.edgecolor);else set(h_,'markeredgecolor',Property.edgecolor);end%% Set object tags (for som_show_clear) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%set(h_,'Tag','Hit')%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function h_=label(Labels, lattice, msize, Property)% number of map unitsmunits=prod(msize);% subplots and handlesp=Property.subplot;handles= Property.handles;% Set default text sizeif isempty(Property.textsize) % default point size Property.textsize=10;end% Check color/set defaultif isempty(Property.textcolor), Property.textcolor='k';end% handles will be collected in h_ for outputh_=[]; %%% Action %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%for i=1:length(p); % set axes axes(handles(p(i))); % store hold state and caxis (for some reason matlab may % change caxis(!?) memhold=ishold; hold on; cax=caxis; % Write labels [S,m,l,t]=som_grid(lattice, msize, ... 'Line','none', ... 'Marker', 'none', ... 'Label', Labels, ... 'LabelColor', Property.textcolor, ... 'LabelSize', Property.textsize); % Get handles h_=[h_;m(:);l(:);t(:)]; % reset hold state and caxis if ~memhold hold off; end caxis(cax);end%%% Set object tags %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%set(h_,'Tag','Lab'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function h_=traj(bmu, lattice, msize, Property)% number of map unitsmunits=prod(msize);% subplots and handlesp=Property.subplot;handles=Property.handles;% Set default text color%if isempty(Property.textcolor), % Property.textcolor='k';%end% Set default text size%if isempty(Property.textsize)% Property.textsize=10;%end% Set default markerif isempty(Property.marker) Property.marker='o';end% Set default markersizeif isempty(Property.markersize) Property.markersize=10;end% Set default markercolorif isempty(Property.markercolor) Property.markercolor='w';end% Set default sizefactorif isempty(Property.sizefactor) %Property.sizefactor=0; Property.sizefactor='hit';end% Set default trajwidthif isempty(Property.trajwidth) Property.trajwidth=3;end% Set default widthfactorif isempty(Property.widthfactor) Property.widthfactor='hit';end% Set default trajcolorif isempty(Property.trajcolor) Property.trajcolor='w';end% if no labels, do a empty cell array for syntax reasons%if isempty(Property.text),% Property.text=cell(munits,1);%endh_=[]; % handles will be collected in h_ for output l=length(bmu); % length of trajectoryC=sparse(munits, munits); % init a connection matrix%%%%%% Action %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Calculate the connection matrix that describes the trajectoryfor i=1:l-1, % The following if structure removes the possible redundancy due % to travels in both directions between two nodes of trajectory % (i.e. reflexivity) I=bmu(i+1);J=bmu(i); %if bmu(i)>bmu(i+1) %else % I=bmu(i);J=bmu(i+1); %end C(I,J)=C(I,J)+1;end% transitive connections are equalC=C+C';% drop reflexive conncetions awayC=spdiags(zeros(munits,1),0,C);% Do labels of trajectory nodes%traj_lab=cell(munits,1);hits=zeros(munits,1);for i=1:l,% traj_lab{bmu(i)}=strvcat(traj_lab{bmu(i)},Property.text{i}); hits(bmu(i))=(hits(bmu(i))+1);end% Calculate unit coordinatesunit_coord=som_vis_coords(lattice, msize);% Calculate line widthif strcmp(Property.widthfactor,'equal') TrajWidth=(C>0)*Property.trajwidth;else TrajWidth=Property.trajwidth.*sqrt(C./max(max(C)));end% Calculate marker sizesif strcmp(Property.sizefactor,'hit') MarkerSize=Property.markersize*sqrt(hits/max(hits));else MarkerSize=Property.markersize*(hits>0);endfor i=1:length(p), axes(handles(p(i))); % Get hold state and caxis memhold=ishold; cax=caxis; hold on; %'Label', traj_lab, ... %'LabelColor', Property.textcolor, ... %'LabelSize', Property.textsize, ... % Draw [S,m,l,t,s]=som_grid(C,msize,'coord',unit_coord,... 'Line','-', ... 'LineColor', Property.trajcolor, ... 'LineWidth', TrajWidth, ... 'Marker', Property.marker, ... 'MarkerColor', Property.markercolor, ... 'MarkerSize', MarkerSize); % Restore hold state and caxis if ~memhold hold off; end caxis(cax); % Get handles h_=[h_;m(:);l(:);t(:);s(:)];end%% Set object tags %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% set(h_,'Tag','Traj');%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function h_=comet(bmu, lattice, msize, Property)% number of map unitsmunits=prod(msize);% subplots and handlesp=Property.subplot;handles=Property.handles;% Set default text color%if isempty(Property.textcolor), % Property.textcolor='k';%end%% Set default text size%if isempty(Property.textsize)% Property.textsize=10;%end% Set default markerif isempty(Property.marker) Property.marker='o';end% Set default markersizeif isempty(Property.markersize), if strcmp(Property.marker,'lattice'), Property.markersize=linspace(0.8,0.1,length(bmu))'; else Property.markersize=sqrt(linspace(400,16,length(bmu)))'; endelse if strcmp(Property.marker,'lattice'), Property.markersize=linspace(Property.markersize(1),... Property.markersize(2), ... length(bmu))'; else Property.markersize=sqrt(linspace(Property.markersize(1).^2,... Property.markersize(2).^2, ... length(bmu)))'; endend% Set default markercolorif isempty(Property.markercolor) Property.markercolor='w';end% Set default edgecolorif isempty(Property.edgecolor), if vis_valuetype(Property.markercolor,{'nx3rgb'}), Property.edgecolor='none'; else Property.edgecolor=Property.markercolor; endendh_=[];l_=[]; % handles will be collected in h_ for output N_bmus=length(bmu); % length of trajectory% if no labels, do a empty cell array for syntax reasons%if isempty(Property.text),% Property.text=cell(N_bmus,1);%end%%%%%% Action %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Calculate unit coordinates for trajectory pointsunit_coord=som_vis_coords(lattice, msize);coord=unit_coord(bmu,:);% Make labels for the _unique_ units that the comet hitsunique_bmu=unique(bmu); % count units%N_labels=length(unique_bmu); %traj_lab=cell(N_labels,1); % cell for labels%label_coord=unit_coord(unique_bmu,:); % label coordinates% Make labels%for i=1:N_bmus,% index=find(unique_bmu==bmu(i));% traj_lab{index}=strvcat(traj_lab{index},Property.text{i});%end%Main loop for drawing cometsfor i=1:length(p), % set axis axes(handles(p(i))); % Get hold state and caxis memhold=ishold; cax=caxis; hold on; if strcmp(Property.marker,'lattice'), % Draw: marker is a patch ('hexa','rect') l_=som_cplane(lattice, coord, Property.markercolor, ... Property.markersize); % Set edgecolor set(l_,'edgecolor',Property.edgecolor); else % Draw: other markers than 'hexa' or 'rect' [S,m,l,t,s]=som_grid(lattice, [N_bmus 1], 'coord', coord,... 'Line','none', ... 'Marker', Property.marker, ... 'MarkerColor', Property.markercolor, ... 'MarkerSize',Property.markersize); % Set edgecolor set(m, 'markeredgecolor', Property.edgecolor); % Get handles from markers h_=[h_;l_(:);m(:);l(:);t(:);s(:)]; end % Set labels %[S,m,l,t,s]=som_grid(lattice, [N_labels 1], 'coord', label_coord,... % 'Marker','none','Line','none',... % 'Label', traj_lab, ... % 'LabelColor', Property.textcolor, ... % 'LabelSize', Property.textsize); % Get handles from labels %h_=[h_;m(:);l(:);t(:);s(:)]; % Restore hold state and caxis if ~memhold hold off; end caxis(cax);end%% Set object tags %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% set(h_,'Tag','Comet');%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function P=init_properties;% Initialize an empty property structP.marker=[];P.markersize=[];P.sizefactor=[];P.markercolor=[];P.edgecolor=[];P.trajwidth=[];P.widthfactor=[];P.trajcolor=[];P.text=[];P.textsize=[];P.textcolor=[];P.subplot=[];P.shift=[];
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -