⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gedagui.m

📁 常用ROBUST STATISTICAL
💻 M
📖 第 1 页 / 共 4 页
字号:
tg = findobj('tag','gedagui');
H = get(tg,'userdata');
ud = get(0,'userdata');
if isempty(ud.X)
    errordlg('You must load some data first.')
    return
end
% Get the dataset to be used.
tmp = get(H.data,'string');
dataset = tmp{get(H.data,'value')};
switch dataset
    case 'X'
        % use the original data data
        data = ud.X;
        xstr = 'X';
    case 'PCA'
        % use PCA field. this is the projection matrix so data =
        % ud.X*ud.pca(:,1:d). 
        data = ud.X*ud.pca;
        xstr = 'PCA';

    case 'LLE'
        data = ud.LLE;
        xstr = 'LLE';
    case 'HLLE'
        data = ud.hLLE;
        xstr = 'HLLE';
    case 'ISOMAP'
        % Check to see what is saved there. Might be the whole thing or
        % might be just what the user outputs. Depends on whether the other
        % gui is open or not.
        % if iscell - then get the right number of dimensions wanted - like
        % pca. else it is double - correct array to just use.
        [n,p] = size(ud.X);
        if ~iscell(ud.isomap)
            data = ud.isomap;
        else
            data = ud.isomap{end}';
        end
        xstr = 'ISOMAP';
        
                
    case 'MDS'
        % Added 11-12-05 - Process the MDS data.
        data = ud.mds;
        xstr = 'MDS';
        
    case 'CMDS'
        % Added 11-12-05 - Process the CMDS data.
        data = ud.cmds;
        xstr = 'CMDS';
        
    case 'PPEDA'
        % Added 11-12-05 - Process the PPEDA data.
        Z = sphere(ud.X);
        data = Z*ud.ppeda;
        xstr = 'PPEDA';
       
end
[n,p] = size(data);
% Get the information for plotting: Dimensions to use.
tmp = get(H.dim3D,'string');
eval(['dim3d = [' tmp '];']);
dim3d = round(dim3d);
if length(dim3d) ~= 3
    errordlg('Must enter three dimensions to plot.')
    return
end
if any(dim3d < 1) | any(dim3d > p)
    errordlg(['Dimensions must be between 1 and ' int2str(p)])
    return
end
if length(unique(dim3d)) < 3
    errordlg('Dimensions must be different.')
    return
end
% Get the color by groups flag.
colflag = get(H.popmode,'value');
% OK to plot
hf = figure;
set(hf,'tag','3D','numbertitle','off','name','EDA: 3-D Scatterplot')
% Upon figure close, this should delete from the array.
set(hf,'CloseRequestFcn',...
    'gedagui(''update'');tg = findobj(''tag'',''gedagui''); H = get(tg,''userdata''); H.plots(find(H.plots == gcf)) = []; set(tg,''userdata'',H); delete(gcf)')

% Set up stuff for brushing/linking. 
set(hf,'RendererMode','manual',...
        'backingstore','off',...
        'renderer','painters',...
        'DoubleBuffer','on');
      
H.plots = [H.plots, hf];
set(tg,'userdata',H)

% Will need to store the handle for this window in the proper field for
% brush/link.
% The following is used for brush/link purposes. 
figure(hf)
fud = [];
switch colflag
    case 1
        % just do a plain plot - do link parallel/Andrews curves - one line
        % per observation. makes it easier to brush/link
        set(hf,'visible','on')
        set(hf,'backingstore','off','renderer','painters','DoubleBuffer','on')
        Hline = zeros(length(data(:,1)),1);
        Hline(1) = plot3(data(1,dim3d(1)),data(1,dim3d(2)),data(1,dim3d(3)),'ko');
        hold on
        for ii = 2:length(data(:,1))
            Hline(ii) = plot3(data(ii,dim3d(1)),data(ii,dim3d(2)),data(ii,dim3d(3)),'ko');
            set(Hline(ii),'markersize',3,'marker','o','linestyle','none',...
            'markerfacecolor','w')
        end
        hold off
        ud.linkptrap = [ud.linkptrap, hf];
        ud.linkap = [ud.linkap, Hline(:)];

        set(0,'userdata',ud)
        % Put proper labels on there. Check to see if any are loaded.
        % This next section added nov 5.
        if strcmp(dataset,'X')
            % Then we are plotting the regular data set. Just use the
            % regular labels.
            xlabel(ud.varlab{dim3d(1)},'handlevisibility','on')
            ylabel(ud.varlab{dim3d(2)},'handlevisibility','on')
            zlabel(ud.varlab{dim3d(3)},'handlevisibility','on')
        else
            % Then we are plotting something else - PCA, etc.
            xlabel([xstr ' ' int2str(dim3d(1))],'handlevisibility','on');
            ylabel([xstr ' ' int2str(dim3d(2))],'handlevisibility','on');
            zlabel([xstr ' ' int2str(dim3d(3))],'handlevisibility','on');
            % set up the string for the popupmenu
        end
        box on
        grid on
        
%         axis manual

    case 2
        % Color by groups - must be loaded by the user. Not from
        % clustering.
        if isempty(ud.classlab)
            errordlg('You must load some group labels.')
            close(hf)
            return
        end
        gscatter3(data(:,dim3d(1)),data(:,dim3d(2)),data(:,dim3d(3)),ud.classlab);
        % This next section added nov 5.
        if strcmp(dataset,'X')
            % Then we are plotting the regular data set. Just use the
            % regular labels.
            xlabel(ud.varlab{dim3d(1)},'handlevisibility','on')
            ylabel(ud.varlab{dim3d(2)},'handlevisibility','on')
            zlabel(ud.varlab{dim3d(3)},'handlevisibility','on')
        else
            % Then we are plotting something else - PCA, etc.
            xlabel([xstr ' ' int2str(dim3d(1))],'handlevisibility','on');
            ylabel([xstr ' ' int2str(dim3d(2))],'handlevisibility','on');
            zlabel([xstr ' ' int2str(dim3d(3))],'handlevisibility','on');
            % set up the string for the popupmenu
        end
    case 3
        % Color by clusters. 
        if isempty(ud.kmeansids) & isempty(ud.agcids) & isempty(ud.mbcids)
            % haven't clustered anything yet.
            errordlg('You must create some clusters first.')
            close(hf)
            return
        end
        menustrg = [];
        cidstr = [];
        if ~isempty(ud.kmeansids)
            menustrg = [menustrg, {'k-Means Clusters'}];
            cidstr = [cidstr, {'ud.kmeansids'}];
        end
        if ~isempty(ud.agcids)
            menustrg = [menustrg, {'Agglomerative Clustering'}];
            cidstr = [cidstr, {'ud.agcids'}];
        end
        if ~isempty(ud.mbcids)
            menustrg = [menustrg, {'Model-Based Clustering'}];
            cidstr = [cidstr, {'ud.mbcids'}];
        end
        if length(cidstr) == 1
            % no need for a listbox. Just plot.
            eval(['gscatter3(data(:,dim3d(1)),data(:,dim3d(2)), data(:,dim3d(3)), ' cidstr{1} ' );'])
            % This next section added nov 5.
            if strcmp(dataset,'X')
                % Then we are plotting the regular data set. Just use the
                % regular labels.
                xlabel(ud.varlab{dim3d(1)},'handlevisibility','on')
                ylabel(ud.varlab{dim3d(2)},'handlevisibility','on')
                zlabel(ud.varlab{dim3d(3)},'handlevisibility','on')
            else
                % Then we are plotting something else - PCA, etc.
                xlabel([xstr ' ' int2str(dim3d(1))],'handlevisibility','on');
                ylabel([xstr ' ' int2str(dim3d(2))],'handlevisibility','on');
                zlabel([xstr ' ' int2str(dim3d(3))],'handlevisibility','on');
                % set up the string for the popupmenu
            end
        else
            [sel,ok] = listdlg('PromptString','Select a type of clustering:',...
                'SelectionMode','single',...
                'ListString',menustrg);
            if ok == 1
                % person selected something.
                eval(['gscatter3(data(:,dim3d(1)),data(:,dim3d(2)), data(:,dim3d(3)), ' cidstr{sel} ' );'])
                % This next section added nov 5.
                if strcmp(dataset,'X')
                    % Then we are plotting the regular data set. Just use the
                    % regular labels.
                    xlabel(ud.varlab{dim3d(1)},'handlevisibility','on')
                    ylabel(ud.varlab{dim3d(2)},'handlevisibility','on')
                    zlabel(ud.varlab{dim3d(3)},'handlevisibility','on')
                else
                    % Then we are plotting something else - PCA, etc.
                    xlabel([xstr ' ' int2str(dim3d(1))],'handlevisibility','on');
                    ylabel([xstr ' ' int2str(dim3d(2))],'handlevisibility','on');
                    zlabel([xstr ' ' int2str(dim3d(3))],'handlevisibility','on');
                    % set up the string for the popupmenu
                end
            end

        end
end


%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function scattermat
% This cannot be brushed or linked. 

tg = findobj('tag','gedagui');
H = get(tg,'userdata');
ud = get(0,'userdata');
if isempty(ud.X)
    errordlg('You must load some data first.')
    return
end
% Get the dataset to be used.
tmp = get(H.data,'string');
dataset = tmp{get(H.data,'value')};
switch dataset
    case 'X'
        % use the original data ud.X
        data = ud.X;
        xstr = 'X';
    case 'PCA'
        % use PCA field. this is the projection matrix so data =
        % ud.X*ud.pca(:,1:d). 
        data = ud.X*ud.pca;
        xstr = 'PCA';

    case 'LLE'
        data = ud.LLE;
        xstr = 'LLE';
    case 'HLLE'
        data = ud.hLLE;
        xstr = 'HLLE';
    case 'ISOMAP'
        % Check to see what is saved there. Might be the whole thing or
        % might be just what the user outputs. Depends on whether the other
        % gui is open or not.
        % if iscell - then get the right number of dimensions wanted - like
        % pca. else it is double - correct array to just use.
        [n,p] = size(ud.X);
        if ~iscell(ud.isomap)
            data = ud.isomap;
        else
            data = ud.isomap{end}';
        end
        xstr = 'ISOMAP';
        
                
    case 'MDS'
        % Added 11-12-05 - Process the MDS data.
        data = ud.mds;
        xstr = 'MDS';
        
    case 'CMDS'
        % Added 11-12-05 - Process the CMDS data.
        data = ud.cmds;
        xstr = 'CMDS';
        
    case 'PPEDA'
        % Added 11-12-05 - Process the PPEDA data.
        Z = sphere(ud.X);
        data = Z*ud.ppeda;
        xstr = 'PPEDA';
       

end
[n,p] = size(data);
% Get the information for plotting: Dimensions to use.
tmp = get(H.dimscatter,'string');
if strcmp(lower(tmp),'all')
    % user wants all dimensions to display.
    dims = 1:p;
else
    eval(['dims = [' tmp '];']);
    dims = round(dims);
end
if any(dims < 1) | any(dims > p)
    errordlg(['Dimensions must be between 1 and ' int2str(p)])
    return
end
if length(unique(dims)) < length(dims)
    errordlg('Dimensions must be different.')
    return
end
% Get the color by groups flag.
colflag = get(H.popmode,'value');
% OK to plot
hf = figure;
set(hf,'tag','scatter','numbertitle','off','name','EDA: Scatterplot Matrix')
% Upon figure close, this should delete from the array.
set(hf,'CloseRequestFcn',...
    'gedagui(''update'');tg = findobj(''tag'',''gedagui''); H = get(tg,''userdata''); H.plots(find(H.plots == gcf)) = []; set(tg,''userdata'',H); delete(gcf)')
set(hf,'RendererMode','manual',...
    'backingstore','off',...
    'renderer','painters',...
    'DoubleBuffer','on');
H.plots = [H.plots, hf];
set(tg,'userdata',H)

% Will need to store the handle for this window in the proper field for
% brush/link.
% The following is used for brush/link purposes. 
figure(hf)
fud = [];
switch colflag
    case 1
        % just do a plain plot
        [H,ax,BigAx,patches,pax] = plotmatrix(data(:,dims));
        % Note that in this case the Hline handles are a 3-D array. (i,j)
        % is for the i,j plot.
        % This plot can be linked.
        % Linking will be taken care of by merging this with the others
        % that are only linkable.
        % need to do some converting. Get rid of diagonal handles.
        %         ind = sub2ind(size(Hline),1:p,1:p);
        %         Hline = Hline(:);
        %         Hline(ind) = [];
        %         ud.linkptr = [ud.linkptr, hf];
        %         ud.link = [ud.link; Hline];
        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -