📄 da_pc3d.m
字号:
%
% da_pc3d.m
%
% menus etc for plotting one principal component
% verus time
%
%
% Draw some axes
%
da_front;
da_pcapb;
drawnow;
w1=gcf;
figure(w1);
ax1=axes(...
'Units','pixels',...
'Position',[60 230 500 170],...
'Box','on',...
'Color',[0 0 0]);
%
% dummy variable to plot on the "up" axis
%
[Dlen Dent]=size(data);
b=1:Dlen;
plot3(pcs(:,2),pcs(:,1),b,'+');
set(ax1,'Xgrid','on');
set(ax1,'Zgrid','off');
set(ax1,'Ygrid','on');
view(20,20);
Xlabel('X-axis');
Ylabel('Y-axis');
Zlabel('Sample number');
%
% Title for the graph
%
text1=da_text(w1,170,410,300,15,'3D Plot of principal component variances',[1 1 1],[1 0 0]);
old_sl4_value=0;
old_sl3_value=0;
sl3_value=1;
sl4_value=2;
%
% Draw slider for rotation
%
sl1=uicontrol(w1,...
'Style','slider',...
'Position',[450 130 100 20],...
'Max',180,...
'Min',0,...
'Value',20,...
'CallBack',[
'set(sl1_current,''String'',ceil(get(sl1,''Value'')));',...
'Zlabel(''Sample number'');',...
'Xlabel(''X-axis'');',...
'Ylabel(''Y-axis'');',...
'view(ceil(get(sl1,''Value'')),ceil(get(sl2,''Value'')));']);
sl1_current=uicontrol(w1,...
'Style','text',...
'Position',[520 150 20 15],...
'String',num2str(ceil(get(sl1,'Value'))),...
'ForeGroundColor',[1 1 1],...
'BackGroundColor',[0 0 0]);
sl1_min=uicontrol(w1,...
'Style','text',...
'Position',[430 130 15 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String','0');
sl1_max=uicontrol(w1,...
'Style','text',...
'Position',[560 130 20 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String','180');
sl1_title=uicontrol(w1,...
'Style','text',...
'Position',[450 150 70 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String','Rotation');
%
% Draw slider for elevation
%
sl2=uicontrol(w1,...
'Style','slider',...
'Position',[450 80 100 20],...
'Max',180,...
'Min',0,...
'Value',20,...
'CallBack',[
'set(sl2_current,''String'',ceil(get(sl2,''Value'')));',...
'Zlabel(''Sample number'');',...
'Xlabel(''X-axis'');',...
'Ylabel(''Y-axis'');',...
'view(ceil(get(sl1,''Value'')),ceil(get(sl2,''Value'')));']);
sl2_current=uicontrol(w1,...
'Style','text',...
'Position',[520 100 20 15],...
'String',num2str(ceil(get(sl2,'Value'))),...
'ForeGroundColor',[1 1 1],...
'BackGroundColor',[0 0 0]);
sl2_min=uicontrol(w1,...
'Style','text',...
'Position',[430 80 15 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String','0');
sl2_max=uicontrol(w1,...
'Style','text',...
'Position',[560 80 20 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String','180');
sl2_title=uicontrol(w1,...
'Style','text',...
'Position',[450 100 70 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String','Elevation');
%
% Slider to determine which pc to plot on the x-axis
%
sl3=uicontrol(w1,...
'Style','slider',...
'Position',[50 80 200 20],...
'Max',num_pcs,...
'Min',1,...
'Value',1,...
'CallBack',[
'set(sl3_current,''String'',num2str(ceil(get(sl3,''Value''))));',...
'sl3_value=ceil(get(sl3,''Value''));',...
'if sl3_value ~= old_sl3_value;',...
'plot3(pcs(:,ceil(get(sl4,''Value''))),pcs(:,sl3_value),b,''+'');',...
'old_sl3_value=sl3_value;',...
'set(ax1,''Xgrid'',''on'');',...
'set(ax1,''Zgrid'',''off'');',...
'set(ax1,''Ygrid'',''on'');',...
'Zlabel(''Sample number'');',...
'Xlabel(''X-axis'');',...
'Ylabel(''Y-axis'');',...
'view(ceil(get(sl1,''Value'')),ceil(get(sl2,''Value'')));',...
'end']);
sl3_current=uicontrol(w1,...
'Style','text',...
'Position',[220 100 50 15],...
'String',num2str(ceil(get(sl3,'Value'))),...
'ForeGroundColor',[1 1 1],...
'BackGroundColor',[0 0 0]);
sl3_min=uicontrol(w1,...
'Style','text',...
'Position',[30 80 15 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String','0');
sl3_max=uicontrol(w1,...
'Style','text',...
'Position',[260 80 20 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String',num2str(num_pcs));
sl3_title=uicontrol(w1,...
'Style','text',...
'Position',[70 100 150 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String','pc plotted on x-axis:');
%
% Slider to determine which principal component to plot on the
% y-axis
%
sl4=uicontrol(w1,...
'Style','slider',...
'Position',[50 130 200 20],...
'Max',num_pcs,...
'Min',1,...
'Value',2,...
'CallBack',[
'set(sl4_current,''String'',num2str(ceil(get(sl4,''Value''))));',...
'sl4_value=ceil(get(sl4,''Value''));',...
'if sl4_value ~= old_sl4_value;',...
'plot3(pcs(:,sl4_value),pcs(:,ceil(get(sl3,''Value''))),b,''+'');',...
'old_sl4_value=sl4_value;',...
'set(ax1,''Xgrid'',''on'');',...
'set(ax1,''Zgrid'',''off'');',...
'set(ax1,''Ygrid'',''on'');',...
'Zlabel(''Sample number'');',...
'view(ceil(get(sl1,''Value'')),ceil(get(sl2,''Value'')));',...
'end']);
sl4_current=uicontrol(w1,...
'Style','text',...
'Position',[220 150 50 15],...
'String',num2str(ceil(get(sl4,'Value'))),...
'ForeGroundColor',[1 1 1],...
'BackGroundColor',[0 0 0]);
sl4_min=uicontrol(w1,...
'Style','text',...
'Position',[30 130 15 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String','0');
sl4_max=uicontrol(w1,...
'Style','text',...
'Position',[260 130 20 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String',num2str(num_pcs));
sl4_title=uicontrol(w1,...
'Style','text',...
'Position',[70 150 150 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String','pc plotted on y-axis:');
%
% Draw "snake" button
%
but2=uicontrol(w1,...
'style','push',...
'position',[500 10 100 20],...
'string','Snake',...
'callback',[...
'comet3a(pcs(:,sl4_value),pcs(:,sl3_value),b);',...
'cla;',...
'plot3(pcs(:,sl4_value),pcs(:,ceil(get(sl3,''Value''))),b,''+'');',...
'set(ax1,''Xgrid'',''on'');',...
'set(ax1,''Zgrid'',''off'');',...
'set(ax1,''Ygrid'',''on'');',...
'view(ceil(get(sl1,''Value'')),ceil(get(sl2,''Value'')));',...
'Zlabel(''Sample number'');']);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -