reverse-shooting

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

chadfig.m (3012B)


      1 function []=chadfig(xlab,ylab,shrinkfactor,dowait,changey);
      2 
      3 % chadfig.m   3/12/04
      4 %
      5 %   function []=chadfig(xlab,ylab,shrinkfactor,dowait,changey);
      6 %
      7 %   changey=0 to leave the yaxis size unchanged.
      8 %
      9 %  Try to produce very high quality figures that look like those in my
     10 %  growth book.
     11 %
     12 %   xlab=xlabel,  ylab=ylabel.  
     13 %
     14 %  Good ideas for nice figures, to implement before calling:
     15 %
     16 %   xlab='Productivity, $\bar{A}$' now works (latex interpreter added)
     17 %   Actually, no, it doesn't work.  The problem is the latex interpreter gets
     18 %   applied to the entire text, overriding bold, etc. and making it look weird.
     19 %
     20 %   xlab=upper(xlab)     %  Upper Case labels
     21 %   set(gca,'LineWidth',1);
     22 %   plot figure with LineWidth=1 as well.
     23 
     24 if exist('shrinkfactor')~=1;
     25    shrinkfactor=1;
     26 end;
     27 if exist('changey')~=1;
     28    changey=1;
     29 end;
     30 if exist('dowait')~=1;
     31    dowait=0;
     32 end;
     33 
     34 %xlabel(xlab,'FontWeight','Bold','FontSize',14);
     35 %ylabel(ylab,'FontWeight','Bold','FontSize',14,'Rotation',0);
     36 %xlabel(xlab,'FontWeight','Bold','Interpreter','latex');
     37 %ylabel(ylab,'FontWeight','Bold','Rotation',0,'Interpreter','latex');
     38 if ~iscell(ylab);
     39   if ylab(1)~=' ';
     40     % add spaces if needed to get centered position
     41     nn=length(ylab);  
     42     if nn>8; ylab=[ones(1,round(1.8*(nn-8)))*' ' ylab]; end; %1.4 for 16pt, 1.8 for 18pt
     43   end;
     44 end;
     45 
     46 if iscell(xlab);
     47     xlabel(xlab,'FontWeight','Bold');
     48 else;
     49   if any(xlab=='$');
     50     xlabel(xlab,'FontWeight','Bold','interpreter','latex');
     51   else;
     52     xlabel(xlab,'FontWeight','Bold');
     53   end;
     54 end;
     55 if iscell(ylab);
     56     ylabel(ylab,'FontWeight','Bold','Rotation',0);
     57 else;
     58   if any(ylab=='$');
     59     ylabel(ylab,'FontWeight','Bold','Rotation',0,'interpreter','latex');
     60     % Note, bold doesn't seem to work in latex model.  Use {\bf } in ylab
     61   else;
     62     ylabel(ylab,'FontWeight','Bold','Rotation',0);
     63   end;
     64 end;
     65 pos=get(get(gca,'YLabel'),'Position');
     66 curaxis=axis;
     67 step=curaxis(4)-curaxis(3);
     68 newaxis=curaxis;
     69 newloc=curaxis(4)+.02*step*changey;  % .03 instead of 0.1
     70 %%%%newaxis(4)=newloc;    3/26/09
     71 axis(newaxis);
     72 pos(2)=newloc;
     73 set(get(gca,'YLabel'),'Position',pos);
     74 set(get(gca,'YLabel'),'HorizontalAlignment','center');
     75 % 3/24 trying left instead of center!
     76 %set(get(gca,'YLabel'),'HorizontalAlignment','left');
     77 blah=get(gca,'YTick');
     78 set(gca,'YTick',blah);
     79 pos=get(get(gca,'XLabel'),'Position');
     80 pos(1)=curaxis(2);
     81 set(get(gca,'XLabel'),'Position',pos);
     82 set(get(gca,'XLabel'),'HorizontalAlignment','right');
     83 set(get(gca,'XLabel'),'VerticalAlignment','top');
     84 
     85 
     86 % Shrink the axes to keep labels from being cut off:
     87 % See              The MathWorks MATLAB Digest
     88 %                   June 1995
     89 %              Volume 3, number 6
     90 
     91 pos = get(gca,'position'); 		% This is in normalized coordinates
     92 pos(3:4)=pos(3:4)*shrinkfactor; 	% Shrink the axis by a factor of .9
     93 pos(1:2)=pos(1:2)+pos(3:4)*(1-shrinkfactor); % Center it in the figure window
     94 set(gca,'position',pos);
     95 
     96 set(gca,'Box','off');
     97 
     98 if dowait;
     99    wait('Adjust any figure settings you want and press Enter');
    100 end;
    101 
    102 refresh;
    103