Back to home page

MITgcm

 
 

    


Warning, /utils/matlab/cs_grid/bk_line/moveHV_colbar.m is written in an unsupported language. File is not indexed.

view on githubraw file Latest commit 4ec37fd8 on 2023-10-03 22:00:32 UTC
4ec37fd829 Jean*0001 function moveHV_colbar(barscale,ori_h0v1)
                0002 % moveHV_colbar(barscale,[ori_h0v1])
                0003 % Draw Horizontal(default) or Vertical (ori_h0v1=1) Colorbar
                0004 %  with scale factor given by barscale
                0005 % e.g.: barscale=[0.8 0.7] --> shift to center AND reduce by 0.2 in H & 0.3 in V
                0006 % e.g.: barscale=[1. .7 .6 .5] --> shift to center by 0.3 in V
                0007 %                            AND reduce by 0.4 in H & 0.5 in V
                0008 
                0009 % Written by jmc@mit.edu, 2006.
                0010 
                0011 wr2std=0;
                0012 if (nargin < 2), ori_h0v1 = 0; end
                0013 nSub=rem(fix(ori_h0v1*1000),1000);
                0014 if nSub ~= 0,
                0015  if wr2std > 0, fprintf(' Arg-2= %6.4f ,',ori_h0v1); end
                0016  nsV=fix(nSub/100);
                0017  nsH=fix(nSub/10-nsV*10);
                0018  js=rem(nSub,10)-1;
                0019  is=rem(js,nsH); js=nsV-1-fix(js/nsH);
                0020  if wr2std > 0,
                0021   fprintf(' nSub= %i , nsH,nsV,is,js= %i %i %i %i\n',nSub,nsH,nsV,is,js);
                0022  end
                0023 end
                0024 ori_h0v1=fix(ori_h0v1);
                0025 %---
                0026 barfac=barscale;
                0027 if size(barscale,2) < 2, barfac(2)=barfac(1) ; end
                0028 if size(barscale,2) < 3, barfac(3)=barfac(1) ; end
                0029 if size(barscale,2) < 4, barfac(4)=barfac(2) ; end
                0030 %---
                0031 if ori_h0v1 == 1
                0032 % BB=colorbar('vertical');
                0033   BB=colorbar('EastOutside');
                0034 else
                0035 % BB=colorbar('horiz');
                0036   BB=colorbar('SouthOutside'); % new syntax
                0037 end
                0038 pos=get(BB,'Position') ;
                0039 if pos(3) < 0 | pos(4) < 0, wr2std=1; end
                0040 if wr2std > 0,
                0041  fprintf(' -- initial colorbar position : %6.4f %6.4f %6.4f %6.4f \n', pos);end
                0042 %- sometimes get Width or Height from colorbar & matlab.7:
                0043 if pos(4) < 0, pos(4)=.0312; pos(2)=0.04; end
                0044 %if pos(3) < 0, pos(2)=.0312; pos(1)=0.04; end
                0045 pos(1) = (0.5-pos(1)-pos(3)*0.5)*barfac(1) ;
                0046 pos(2) = (0.5-pos(2)-pos(4)*0.5)*barfac(2) ;
                0047 pos(3) = pos(3)*barfac(3) ;
                0048 pos(4) = pos(4)*barfac(4) ;
                0049 pos(1) = 0.5-pos(1)-pos(3)*0.5 ;
                0050 pos(2) = 0.5-pos(2)-pos(4)*0.5 ;
                0051 if nSub ~= 0,
                0052  pos(1)=0.03+0.90/nsH+(0.90/nsH)*is;
                0053  pos(2)=0.07+0.15/nsV+(0.89/nsV)*js;
                0054 end
                0055 if wr2std > 0,
                0056  fprintf(' - modified colorbar position : %6.4f %6.4f %6.4f %6.4f \n', pos);end
                0057 if pos(3) < 0 | pos(4) < 0 ,
                0058   errmsg=sprintf(' colorbar: width or height must be > 0: %6.4f %6.4f', pos(3:4));
                0059   error(errmsg)
                0060 end
                0061 set(BB,'Position',pos);
                0062 return