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

📄 ipcascoplotg.m

📁 这是国外一个PLS工具箱
💻 M
字号:
function ipcascoplot(Model,PCa,PCb,samplenames,classvariable,no_of_plots_pr_figure)

% modified version of  
% ipcascoplot makes 2D score plots of PCa versus PCb for all intervals
% use function gscatter and scatter and a modified version of gname
% for plotting scatter plot of score plot
%  
% Input:
%  Model (the output from ipca.m)
%  PCa and PCb designates the combination of score vectors to use in the plot
%  samplenames: string, see makeSampleNames for an example (use [] if not available)
%  %  no_of_plot_pr_figure must be 2, 4, 6 or 8 (optional, default is 6)
%
%  Copyright, Chemometrics Group - KVL, Copenhagen, Denmark
%  Lars N鴕gaard, July 2004
%
%  ipcascoplot(Model,PCa,PCb,samplenames,classvariable,no_of_plots_pr_figure);

if nargin==0
    disp(' ')
    disp(' ipcascoplot(Model,PCa,PCb,samplenames,classvariable,no_of_plots_pr_figure);')
    disp(' ')
    disp(' Example:')
    disp(' ipcascoplot(Model,1,2,[],classes);')
    disp(' ')
    return
end
[n,m] = size(Model.rawX);
set(0,'Units','pixels');
Scrsiz=get(0,'ScreenSize');
ScrLength=Scrsiz(3);
ScrHight=Scrsiz(4);
bdwidth=10;
% [left(->) bottom(up) width hight]
figpos=[0.1*ScrLength 0.15*ScrHight 0.85*ScrLength 0.75*ScrHight];
% Plot score plot for global model
figure(1)
set(1,'Position',figpos)
if isempty(classvariable)
scatter(Model.PCAmodel{size(Model.allint,1)}.T(:,PCa),Model.PCAmodel{size(Model.allint,1)}.T(:,PCb))
else
gscatter(Model.PCAmodel{size(Model.allint,1)}.T(:,PCa),Model.PCAmodel{size(Model.allint,1)}.T(:,PCb),classvariable)
end
if isempty(Model.xaxislabels)==1
   title(sprintf('Global model, Variables %g-%g',Model.allint(1,2),Model.allint(size(Model.allint,1),3)));
else
   wavstart=Model.xaxislabels(Model.allint(1,2));
   wavend=Model.xaxislabels(Model.allint(size(Model.allint,1),3));
   title(sprintf('Global model, Var. %g-%g, Wav. %g-%g',Model.allint(1,2),Model.allint(size(Model.allint,1),3),wavstart,wavend));
end
xlabel(sprintf('PC %g',PCa))
ylabel(sprintf('PC %g',PCb))
hold on
V=axis;
if sign(V(1))==sign(V(2)) & sign(V(3))==sign(V(4))
    % No lines through origo
elseif sign(V(1))==sign(V(2))
    plot([V(1) V(2)],[0 0],'-g')
elseif sign(V(3))==sign(V(4))
    plot([0 0],[V(3) V(4)],'-g')
else
    plot([V(1) V(2)],[0 0],'-g',[0 0],[V(3) V(4)],'-g')
end
gname_m(samplenames)
hold off
% Plot score plots for local models
if nargin<6 | ~ismember(no_of_plots_pr_figure,[1 2 4 6 8])
   no_of_plots_pr_figure=6;
end
No_of_figures=ceil(Model.intervals/no_of_plots_pr_figure);
count=0;
for i=1:No_of_figures
   figure(i+1)
   set(i+1,'Position',figpos)
   for j=1:no_of_plots_pr_figure
      count=count+1;
      if count>Model.intervals, break, end
      if no_of_plots_pr_figure==1
          % One plot in one Figure
      elseif no_of_plots_pr_figure==2
          subplot(1,2,j)
      elseif no_of_plots_pr_figure==4
          subplot(2,2,j)
      elseif no_of_plots_pr_figure==8
          subplot(4,2,j)          
      else   %no_of_plots_pr_figure==6
          subplot(3,2,j)
      end
      if isempty(classvariable)
          scatter(Model.PCAmodel{count}.T(:,PCa),Model.PCAmodel{count}.T(:,PCb))
      else
          gscatter(Model.PCAmodel{count}.T(:,PCa),Model.PCAmodel{count}.T(:,PCb),classvariable)
      end
          if isempty(Model.xaxislabels)==1
        title(sprintf('Int%g, Variables %g-%g',count,Model.allint(count,2),Model.allint(count,3)));
      else
        wavstart=Model.xaxislabels(Model.allint(:,2));
        wavend=Model.xaxislabels(Model.allint(:,3));
        title(sprintf('Int%g, Var. %g-%g, Wav. %g-%g',count,Model.allint(count,2),Model.allint(count,3),wavstart(count),wavend(count)));
      end
      xlabel(sprintf('PC %g',PCa))
 	  ylabel(sprintf('PC %g',PCb))
	  hold on
	  V=axis;
      if sign(V(1))==sign(V(2)) & sign(V(3))==sign(V(4))
          % No lines through origo
	  elseif sign(V(1))==sign(V(2))
            plot([V(1) V(2)],[0 0],'-g')
	  elseif sign(V(3))==sign(V(4))
            plot([0 0],[V(3) V(4)],'-g')
	  else
            plot([V(1) V(2)],[0 0],'-g',[0 0],[V(3) V(4)],'-g')
      end
      gname_m(samplenames)
      hold off
   end
end

⌨️ 快捷键说明

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