reverse-shooting

Matlab scripts for reverse shooting
Log | Files | Refs | README

plotlog.m (1804B)


      1 function []=plotlog(x,y,sym,axlabel,fsize,color,shiftx,shifty,namethese);
      2 %  function []=plotlog(x,y,sym,axlabel);
      3 %
      4 %  Plots y vs x with y on a log scale (natural log).
      5 %
      6 %  sym is a symbols argument:  if a string, then just pass it
      7 %     along to plot.  If a vector, then use as plotname.
      8 %
      9 %  axlabel is the string to use to label the y axis.
     10 
     11 if exist('sym')~=1; sym='-';end;
     12 if exist('axlabel')~=1; axlabel=[];end;
     13 if exist('fsize')~=1; fsize=8; end;
     14 if exist('color')~=1; color=[0 .4 0]; end;
     15 if exist('namethese')~=1; namethese=[]; end;
     16 
     17 if size(sym,1)==1;
     18    plot(x,log(y),sym);
     19 else;
     20   if size(sym,2)<4;  % If you send 3 letter codes, just those, else sym and name
     21     plotname(x,log(y),sym,fsize,color);
     22   else;
     23     plotnamesym2(x,log(y),sym,fsize,color,shiftx,shifty,namethese);
     24   end;
     25 end;
     26 
     27 % Now fix the log scale for the y axis.
     28 %val=[1000 2000 4000 8000 16000 32000]';
     29 %labs=strmat('1000 2000 4000 8000 16000 32000');
     30 if isempty(axlabel);
     31    curlabs=get(gca,'YTickLabel');
     32    newnum=exp(str2num(curlabs));
     33    newlabs=num2str(newnum,'%6.0f');
     34    if any(delta(str2num(newlabs))==0);
     35 %   if size(newlabs,2)==1; 		% Add another significant digit
     36       newlabs=num2str(newnum,'%6.1f');
     37       set(gca,'YTick',log(1/10*round(newnum*10)));
     38    else;
     39       set(gca,'YTick',log(round(newnum)));
     40    end;
     41    set(gca,'YTickLabel',newlabs);
     42 %  Old error:   set(gca,'YTick',str2num(curlabs));  %But there is rounding!!!!
     43 else;
     44    if size(axlabel,1)==1; labs=strmat(axlabel); else; labs=axlabel; end;
     45    logval=log(str2num(axlabel));
     46    set(gca,'YTick',logval);
     47    set(gca,'YTickLabel',labs);
     48    % Also adjust YLim in case one of labels is outside the range:
     49    curlim=get(gca,'YLim');
     50    curlim(1)=min([curlim(1) min(logval)]');
     51    curlim(2)=max([curlim(2) max(logval)]');
     52    set(gca,'YLim',curlim);
     53 end;