Skip to content
Snippets Groups Projects
show_crp.m 5.42 KiB
Newer Older
marwan's avatar
marwan committed
function show_crp(X,Shuttle)
% SHOW_CRP   Plots the CRP into the GUI
%    Used by CRP Toolbox

marwan's avatar
marwan committed
% Copyright (c) 2008-2009
% Norbert Marwan, Potsdam Institute for Climate Impact Research, Germany
% http://www.pik-potsdam.de
%
% Copyright (c) 1998-2008
marwan's avatar
marwan committed
% Norbert Marwan, Potsdam University, Germany
% http://www.agnld.uni-potsdam.de
%
% $Date$
% $Revision$
%
% $Log$
% Revision 4.15  2014/10/06 07:18:41  marwan
% bug in colorbar scaling fixed
%
marwan's avatar
marwan committed
% Revision 4.14  2009/03/24 08:36:04  marwan
% copyright address updated
%
marwan's avatar
marwan committed
% Revision 4.13  2008/02/25 11:45:27  marwan
% fix of the colorbar bug
%
marwan's avatar
marwan committed
% Revision 4.12  2007/05/22 13:43:45  marwan
% added fixed RR support
%
marwan's avatar
marwan committed
% Revision 4.11  2006/03/29 13:07:40  marwan
% problems regarding OPRPs and embedding resolved
%
% Revision 4.10  2005/04/15 09:03:03  marwan
% minor bugfix in plugin section
%
marwan's avatar
marwan committed
% Revision 4.9  2005/04/08 09:51:46  marwan
% plugin added
%
marwan's avatar
marwan committed
% Revision 4.8.1.3  2005/04/08 09:03:53  marwan
% plugin added
%
% Revision 4.8.1.2  2005/03/16 12:21:30  marwan
% add support for joint recurrence plots
%
% Revision 4.8.1.1  2004/11/12 08:41:27  marwan
% bug fix in order patterns recurrence plot
%
% Revision 4.8  2004/11/11 12:17:55  marwan
% order patterns recurrence plot added
%
% Revision 4.7  2004/11/10 07:04:29  marwan
% initial import
%
marwan's avatar
marwan committed
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or any later version.

global errcode

NX=size(X,2);
NY=size(X,1);


  switch(Shuttle.mflag)

marwan's avatar
marwan committed
  case {1,2,3,4,5,6,7,8,9}
marwan's avatar
marwan committed

  errcode=12;
  set(findobj('Tag','CRPData',...
              'Parent',findobj('Parent',Shuttle.hCRP,'Tag','CRPPlot')),...
              'visible','on',...
              'xdata',Shuttle.xscale(1:NX),...
marwan's avatar
marwan committed
              'ydata',Shuttle.yscale(1:NY),...
marwan's avatar
marwan committed
              'cdata',uint8(X),'UserData',X)
marwan's avatar
marwan committed
  set(Shuttle.hCRP,'colormap',flipud(gray(2)))
  titletext=sprintf('%s \n',[Shuttle.txt_cross,'Recurrence Plot'],...
      ['Dimension: ', num2str(Shuttle.m), ',  Delay: ', num2str(Shuttle.t), ...
       ',  Threshold: ', Shuttle.matext ]);

marwan's avatar
marwan committed
  if Shuttle.mflag == 8
    titletext=sprintf('%s\n',['Order Matrix']);
marwan's avatar
marwan committed
  elseif Shuttle.mflag == 9
marwan's avatar
marwan committed
    titletext=sprintf('%s\n',['Order Patterns ', Shuttle.txt_cross,'Recurrence Plot',10,...
           'Dimension: ', num2str(Shuttle.m), ' (',num2str(factorial(Shuttle.m)),' order patterns),  Delay: ', num2str(Shuttle.t)]);
marwan's avatar
marwan committed
  end

marwan's avatar
marwan committed
  case {10,11,12}
marwan's avatar
marwan committed

  errcode=13;warning on
  X=double(X);
  if ~isempty(get(findobj('Tag','CRPData','Parent',findobj('Parent',Shuttle.hCRP,'Tag','CRPPlot')),'UserData'))
    h1=get(Shuttle.hCRP,'ColorMap');
    if size(h1,1)==2 
       h1=findobj('Parent',findobj('Parent',Shuttle.hCRP,'Tag','cm'),'Checked','On');  
       c=str2num(get(h1,'Tag'));
       v=[1 2 4 6 8];
       h2=repmat(Shuttle.cm{c},v(get(findobj('Tag','Log','Parent',Shuttle.hCtrl),'value')),1);
       h1=h2(1:v(get(findobj('Tag','Log','Parent',Shuttle.hCtrl),'value')):end,:);
    end
    figure(Shuttle.hCRP)
    set(Shuttle.hCRP,'colormap',h1)
  else
    h1=findobj('Parent',findobj('Parent',Shuttle.hCRP,'Tag','cm'),'Checked','On');  
    c=str2num(get(h1,'Tag'));
    h1=Shuttle.cm{c};
    set(Shuttle.hCRP,'colormap',h1)
  end
marwan's avatar
marwan committed
%  zl=0:max(X(:))/9:max(X(:));
%  zl=fix(zl*100)/100;  
%  X_show=uint8(round(255*X/max(X(:))));
  X_show=double(X);
marwan's avatar
marwan committed
  set(findobj('Tag','CRPData','Parent',findobj('Parent',Shuttle.hCRP,'Tag','CRPPlot')),'visible','on',...
              'xdata',Shuttle.xscale(1:NX),'ydata',Shuttle.yscale(1:NY),...
marwan's avatar
marwan committed
	      'cdata',X_show,'UserData',X)
marwan's avatar
marwan committed
  set(get(findobj('Tag','ColBar','Parent',Shuttle.hCRP),'children'),'visible','on')
marwan's avatar
marwan committed
  
  h1=findobj('Tag','Colorbar','Parent',Shuttle.hCRP);
marwan's avatar
marwan committed
  set(h1,'visible','on')
  set(get(h1,'xlabel'),'string','Dist. to Next Recurrence Point') 
  b2=get(h1,'position');
  b3=get(h1,'ticklength');
marwan's avatar
marwan committed

  %set(h1,'ticklength',[b3(1)/2 b3(2)]) % does not work since MATLAB 2014b
marwan's avatar
marwan committed
  titletext=sprintf('%s \n',[Shuttle.txt_cross,'Distance Matrix'],...
marwan's avatar
marwan committed
          ['Dimension: ', num2str(Shuttle.m), ',  Delay: ', num2str(Shuttle.t)]);
 
  clear v h1 h2
 
 end % switch
 
  errcode=14;
  set(findobj('Tag','CRPPlot','Parent',Shuttle.hCRP),'tickdir','out','box','on',...
    'xlim',[Shuttle.xscale(1) Shuttle.xscale(NX)],...
    'ylim',[Shuttle.yscale(1) Shuttle.yscale(NY)])

  set(findobj('Tag','DataPlot2','Parent',Shuttle.hCRP),'xlim',[Shuttle.xscale(1) Shuttle.xscale(NX)])
    if get(findobj('Tag','Stretch','Parent',Shuttle.hCtrl),'value')==1
       set(findobj('Tag','CRPPlot','Parent',Shuttle.hCRP),'PlotBoxAspectRatio',[max(NX, NY) max(NX, NY) 1])
       set(findobj('Tag','DataPlot1','Parent',Shuttle.hCRP),'xlim',[Shuttle.yscale(1) Shuttle.yscale(NY)])
    elseif get(findobj('Tag','Stretch','Parent',Shuttle.hCtrl),'value')==0
       set(findobj('Tag','CRPPlot','Parent',Shuttle.hCRP),'PlotBoxAspectRatio',[NX NY 1])
       set(findobj('Tag','DataPlot1','Parent',Shuttle.hCRP),'xlim',[Shuttle.xscale(1) Shuttle.xscale(NX)])
    end

  set(get(findobj('Tag','CRPPlot','Parent',Shuttle.hCRP),'title'),'String',titletext)
  
  set(findobj('Tag','Status','Parent',findobj('Parent',Shuttle.hCRP,'Tag','CRPPlot')),'visible','off',...
         'position',[abs(Shuttle.xscale(1))+abs(Shuttle.xscale(NX)-Shuttle.xscale(1))/2 ...
         abs(Shuttle.yscale(1))+abs(Shuttle.yscale(NY)-Shuttle.yscale(1))/2 0])

  set(findobj('Tag','Status','Parent',findobj('Parent',Shuttle.hCRP,'Tag','CRPPlot')),'String','busy...')
  clear X