reverse-shooting

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

plotloglog.m (2818B)


      1 function []=plotloglog(x,y,sym,axlabelx,axlabely,fsize,color,shiftx,shifty,namethese);
      2 %  function []=plotloglog(x,y,sym,axlabelx,axlabely,fsize,color,shiftx,shifty,namethese);
      3 %
      4 %  Plots y vs x with BOTH x AND 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('axlabelx')~=1; axlabel=[];end;
     13 if exist('axlabely')~=1; axlabel=[];end;
     14 if exist('fsize')~=1; fsize=8; end;
     15 if exist('color')~=1; color=[0 .4 0]; end;
     16 if isempty('color'); color=[0 .4 0]; end;
     17 if exist('namethese')~=1; namethese=[]; end;
     18 
     19 if size(sym,1)==1;
     20    plot(log(x),log(y),sym);
     21 else;
     22     %if size(sym,2)<4;  % If you send 3 letter codes, just those, else sym and name
     23     %plotname(log(x),log(y),sym,fsize,color);
     24     %else;
     25     plotnamesym2(log(x),log(y),sym,fsize,color,shiftx,shifty,namethese);
     26     %end;
     27 end;
     28 
     29 % Now fix the log scale for the y axis.
     30 if isempty(axlabely);
     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(axlabely,1)==1; labs=strmat(axlabely); else; labs=axlabely; end;
     45    logval=log(str2num(axlabely));
     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;
     54 
     55 % Now fix the log scale for the x axis.
     56 if isempty(axlabelx);
     57    curlabs=get(gca,'XTickLabel');
     58    newnum=exp(str2num(curlabs));
     59    newlabs=num2str(newnum,'%6.0f');
     60    if any(delta(str2num(newlabs))==0);
     61 %   if size(newlabs,2)==1; 		% Add another significant digit
     62       newlabs=num2str(newnum,'%6.1f');
     63       set(gca,'XTick',log(1/10*round(newnum*10)));
     64    else;
     65       set(gca,'XTick',log(round(newnum)));
     66    end;
     67    set(gca,'XTickLabel',newlabs);
     68 %  Old error:   set(gca,'YTick',str2num(curlabs));  %But there is rounding!!!!
     69 else;
     70    if size(axlabelx,1)==1; labs=strmat(axlabelx); else; labs=axlabelx; end;
     71    logval=log(str2num(axlabelx));
     72    set(gca,'XTick',logval);
     73    set(gca,'XTickLabel',labs);
     74    % Also adjust YLim in case one of labels is outside the range:
     75    curlim=get(gca,'XLim');
     76    curlim(1)=min([curlim(1) min(logval)]');
     77    curlim(2)=max([curlim(2) max(logval)]');
     78    set(gca,'XLim',curlim);
     79 end;