📄 da_pc2d.m
字号:
%
% da_pc2d.m
%
% menus etc for plotting one principal component
% verus time
%
%
% Sort the screen out
%
da_front;
da_pcapb;
drawnow;
ax1=axes(...
'Units','pixels',...
'Position',[50 150 500 250],...
'Box','on',...
'Color',[0 0 0],...
'Visible','on');
%
% Print a title
%
text1=da_text(w1,190,405,250,15,'2D plot of principal component variances',[1 1 1],[1 0 0]);
%
% Plot the principal component
%
plot(pcs(:,1),pcs(:,2),'+');
Xlabel('Principal component score');
Ylabel('Principal component score');
old_val1=1;
old_val2=2;
sl1_value=1;
sl2_value=2;
p_style=0;
[dummy num_pcs]=size(pcs);
%
% Have a slider to change which pc to plot
%
sl1=uicontrol(w1,...
'Style','slider',...
'Position',[50 60 200 20],...
'Min',1,...
'Max',num_pcs,...
'Value',1,...
'CallBack',[
'set(sl1_current,''String'',ceil(get(sl1,''Value'')));',...
'sl1_value=ceil(get(sl1,''Value''));',...
'if sl1_value ~= old_val1;',...
'set(sl1_current,''String'',num2str(ceil(sl1_value)));',...
'if p_style == 0;',...
'cla;',...
'plot(pcs(:,sl1_value),pcs(:,sl2_value),''+'');',...
'else;',...
'cla;',...
'plotnum(pcs(:,sl1_value),pcs(:,sl2_value),ax1);',...
'end;',...
'old_val1=sl1_value;',...
'Xlabel(''Principal component score'');',...
'Ylabel(''Principal component score'');',...
'end;']);
sl1_current=uicontrol(w1,...
'Style','text',...
'Position',[225 85 20 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String',num2str(get(sl1,'Value')));
sl1_min=uicontrol(w1,...
'Style','text',...
'Position',[30 60 15 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String','1');
sl1_max=uicontrol(w1,...
'Style','text',...
'Position',[250 60 20 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String',num2str(num_pcs));
sl1_title=uicontrol(w1,...
'Style','text',...
'Position',[45 85 180 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String','X-axis principal component');
%
% Now draw a slider to define the principal component plotted
% on the y-axis
%
sl2=uicontrol(w1,...
'Style','slider',...
'Position',[370 60 200 20],...
'Min',1,...
'Max',num_pcs,...
'Value',sl2_value,...
'CallBack',[
'set(sl2_current,''String'',ceil(get(sl2,''Value'')));',...
'sl2_value=ceil(get(sl2,''Value''));',...
'if sl2_value ~= old_val2;',...
'set(sl1_current,''String'',num2str(ceil(sl1_value)));',...
'if p_style == 0;',...
'cla;',...
'plot(pcs(:,sl1_value),pcs(:,sl2_value),''+'');',...
'else;',...
'cla;',...
'plotnum(pcs(:,sl1_value),pcs(:,sl2_value),ax1);',...
'end;',...
'old_val2=sl2_value;',...
'Xlabel(''Principal component score'');',...
'Ylabel(''Principal component score'');',...
'end;']);
sl2_current=uicontrol(w1,...
'Style','text',...
'Position',[550 85 20 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String',num2str(get(sl2,'Value')));
sl2_min=uicontrol(w1,...
'Style','text',...
'Position',[350 60 15 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String','1');
sl2_max=uicontrol(w1,...
'Style','text',...
'Position',[570 60 20 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String',num2str(num_pcs));
sl2_title=uicontrol(w1,...
'Style','text',...
'Position',[370 85 170 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String','Y-axis principal component');
%
% Draw "snake" button
%
but2=uicontrol(w1,...
'style','push',...
'position',[500 10 100 20],...
'string','Snake',...
'callback',[...
'comet1(pcs(:,sl1_value),pcs(:,sl2_value));',...
'cla;',...
'if p_style == 0;',...
'cla;',...
'plot(pcs(:,sl1_value),pcs(:,sl2_value),''+'');',...
'else;',...
'cla;',...
'plotnum(pcs(:,sl1_value),pcs(:,sl2_value),ax1);',...
'end;',...
'Xlabel(''Principal component score'');',...
'Ylabel(''Principal component score'');']);
%
% Two buttons for plot numbers or plot crosses
%
but3=uicontrol(w1,...
'style','push',...
'position',[560 350 55 30],...
'string','1,2,3,...',...
'callback',[
'cla;',...
'plotnum(pcs(:,sl1_value),pcs(:,sl2_value),ax1);',...
'p_style=1;']);
but4=uicontrol(w1,...
'style','push',...
'position',[560 300 55 30],...
'string','+++',...
'callback',[
'cla;',...
'plot(pcs(:,sl1_value),pcs(:,sl2_value),''+'');',...
'p_style=0;']);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -