📄 gedagui.m
字号:
% First reset the stuff to black and the same size as others.
% Then also put the tag on there.
for i = 1:length(dims)
for j = i:length(dims)
set(H(i,j),'markersize',3,'marker','o','linestyle','none',...
'markerfacecolor','w','color','k',...
'tag','black')
set(H(j,i),'markersize',3,'marker','o','linestyle','none',...
'markerfacecolor','w','color','k',...
'tag','black')
end
end
pp = length(dims);
% just need the axes for highlighting. Do not add this to the brushing one.
ind = sub2ind(size(ax),1:pp,1:pp);
ax = ax(:);
ax(ind) = [];
% Save handles to highlighted axes in here.
ud.highlight = [ud.highlight,ax'];
set(0,'userdata',ud)
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
% No variable labels with this one - histograms on diagonal.
gplotmatrix(data(:,dims),[],ud.classlab,[],[],[],'no');
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(['gplotmatrix(data(:,dims),data(:,dims), ' cidstr{1} ' );'])
else
[sel,ok] = listdlg('PromptString','Select a type of clustering:',...
'SelectionMode','single',...
'ListString',menustrg);
if ok == 1
% person selected something.
eval(['gplotmatrix(data(:,dims),data(:,dims), ' cidstr{sel} ' );'])
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%
function brushlink
% This function will not do any color stuff, so no need to worry about
% color, brushing or linking.
% NOTE that this plot will NOT be closed with the GUI like the others.
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.dimbrush,'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
% Set up the string array for plotting purposes.
if strcmp(dataset,'X')
% Then we are plotting the regular data set. Just use the regular
% labels.
labstrg = ud.varlab(dims);
else
% we are plotting something else - PCA, etc.
for ii = 1:length(dims)
labstrg{ii} = [xstr ' ' int2str(dims(ii))];
end
end
% This function will create its own figure. Do not mess with the function -
% too many things can get messed up!!!!!
brushscatter(data(:,dims),labstrg);
% Set some housekeeping things.
hf = findobj('Name','Scatterplot Brushing');
set(hf,'numbertitle','off','name','EDA: Scatterplot Matrix Brushing')
% set(hf,'tag','brush','numbertitle','off','name','EDA: Scatterplot Matrix Brushing')
% Upon figure close, this should delete from the array.
set(hf,'CloseRequestFcn',...
'tg = findobj(''tag'',''gedagui''); H = get(tg,''userdata''); H.plots(find(H.plots == gcf)) = []; set(tg,''userdata'',H); delete(gcf)')
H.plots = [H.plots, hf];
set(tg,'userdata',H)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DO ANDREWS CURVES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function doandrews
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.dimandrews,'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','andrews','numbertitle','off','name','EDA: Andrews'' Curves')
set(hf,'backingstore','off','renderer','painters','DoubleBuffer','on')
% 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)')
H.plots = [H.plots, hf];
set(tg,'userdata',H)
figure(hf)
fud = [];
switch colflag
case 1
% just do a plain plot
Hline = andrews(data(:,dims),0);
% This is a vector of handles - each observation has a handle.
ud.linkptrap = [ud.linkptrap, hf];
ud.linkap = [ud.linkap, Hline(:)];
set(0,'userdata',ud)
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
andrews(data(:,dims),1,ud.classlab);
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(['andrews(data(:,dims),1, ' cidstr{1} ' );'])
else
[sel,ok] = listdlg('PromptString','Select a type of clustering:',...
'SelectionMode','single',...
'ListString',menustrg);
if ok == 1
% person selected something.
eval(['andrews(data(:,dims),1, ' cidstr{sel} ' );'])
end
end
end
title(xstr)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
function Hline = andrews(data,colflag,g)
% Hline is a vector of line handles.
% g is a vector of class labels.
[n,p] = size(data);
% THe following gets the axis lines.
% axis off
hax = axes('position',[0.05 0.075 0.9 0.8]);
set(hax,'visible','off')
set(hax,'xlimmode','manual')
set(hax,'xlim',[-pi pi])
axis off
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -