reverse-shooting

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

plotnamesym.m (1146B)


      1 % plotnamesym.m
      2 %
      3 % Creates a plot using the names 'names' and symbols in the
      4 % graph.  
      5 
      6 function h=plotnamesym(x,y,names,fsize,color,shiftx,shifty,addols,markercolor);
      7 
      8 if exist('fsize')~=1; fsize=9; end;
      9 if exist('color')~=1; color=[0 .4 0]; end;
     10 if exist('markercolor')~=1; markercolor='b'; end;
     11 if isempty(color); color=[0 .4 0]; end;
     12 if exist('shiftx')~=1; shiftx=.08; end;
     13 if exist('shifty')~=1; shifty=.05; end;
     14 if exist('addols')~=1; addols=0; end;
     15 
     16 h=plot(x,y,'o','Color',markercolor,'MarkerFaceColor',markercolor,'MarkerSize',3);
     17 
     18 epX=meannan(abs(x))*shiftx;
     19 epY=-meannan(abs(y))*shifty;
     20 for i=1:length(x);
     21   text(x(i)+epX,y(i)+epY,names(i,:),'Color',color,'FontSize',fsize)
     22 end;
     23 
     24 if addols>0;
     25   hold on;
     26   
     27   [b tstat sigma2 vcv rsq]=lstiny(y,[ones(length(x),1) x]);
     28   se = b(2)/tstat(2);
     29   bstr=sprintf('OLS Slope = %7.3f\n',b(2));
     30   sstr=sprintf(' Std. Err.    = %7.3f\n',se);
     31   rstr=sprintf('        R^2      = %7.2f\n',rsq);
     32 
     33   yfit=[ones(length(x),1) x]*b;
     34   [xmin,imin]=min(x);
     35   [xmax,imax]=max(x);
     36   plot([xmin xmax],yfit([imin imax]),'-');
     37 
     38   if addols==1;
     39     putstr(bstr);
     40     putstr(sstr);
     41     putstr(rstr);
     42   end;
     43   
     44 end;