reverse-shooting

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

chadgraph.m (2867B)


      1 function []=chadgraph(xlab,ylab,shrinkfactor,dowait);
      2 
      3 % chadgraph.m   3/12/04
      4 %
      5 %   function []=chadgraph(xlab,ylab,shrinkfactor);
      6 %
      7 %  Key:  chadgraph turns off the axis labels, e.g. for xfig like graphs.
      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=upper(xlab)     %  Upper Case labels
     17 %   set(gca,'LineWidth',1);
     18 %   plot figure with LineWidth=1 as well.
     19 %
     20 %  More ideas:
     21 % $$$ mystr(1)={'\bf IS-Gap'};
     22 % $$$ mystr(2)={'\bf   Curve'};
     23 % $$$ text(10.5,2.5,mystr,'HorizontalAlignment','right');
     24 
     25 if exist('shrinkfactor')~=1;
     26    shrinkfactor=1;
     27 end;
     28 if exist('dowait')~=1;
     29    dowait=0;
     30 end;
     31 
     32 %xlabel(xlab,'FontWeight','Bold','FontSize',14);
     33 %ylabel(ylab,'FontWeight','Bold','FontSize',14,'Rotation',0);
     34 %xlabel(xlab,'FontWeight','Bold','Interpreter','latex');
     35 %ylabel(ylab,'FontWeight','Bold','Rotation',0,'Interpreter','latex');
     36 if ~iscell(ylab);
     37   if ylab(1)~=' ';
     38     % add spaces if needed to get centered position
     39     nn=length(ylab);  
     40     if nn>8; ylab=[ones(1,round(1.8*(nn-8)))*' ' ylab]; end; %1.4 for 16pt, 1.8 for 18pt
     41   end;
     42 end;
     43 
     44 if iscell(xlab);
     45     xlabel(xlab,'FontWeight','Bold');
     46 else;
     47   if any(xlab=='$');
     48     xlabel(xlab,'FontWeight','Bold','interpreter','latex');
     49   else;
     50     xlabel(xlab,'FontWeight','Bold');
     51   end;
     52 end;
     53 if iscell(ylab);
     54     ylabel(ylab,'FontWeight','Bold');
     55 else;
     56   if any(ylab=='$');
     57     ylabel(ylab,'FontWeight','Bold','Rotation',0,'interpreter','latex');
     58   else;
     59     ylabel(ylab,'FontWeight','Bold','Rotation',0);
     60   end;
     61 end;
     62 pos=get(get(gca,'YLabel'),'Position');
     63 curaxis=axis;
     64 step=curaxis(4)-curaxis(3);
     65 newaxis=curaxis;
     66 newloc=curaxis(4)+.02*step;  % .03 instead of 0.1
     67 %%%%newaxis(4)=newloc;    3/26/09
     68 axis(newaxis);
     69 pos(2)=newloc;
     70 set(get(gca,'YLabel'),'Position',pos);
     71 set(get(gca,'YLabel'),'HorizontalAlignment','center');
     72 % 3/24 trying left instead of center!
     73 %set(get(gca,'YLabel'),'HorizontalAlignment','left');
     74 blah=get(gca,'YTick');
     75 set(gca,'YTick',blah);
     76 pos=get(get(gca,'XLabel'),'Position');
     77 pos(1)=curaxis(2);
     78 set(get(gca,'XLabel'),'Position',pos);
     79 set(get(gca,'XLabel'),'HorizontalAlignment','right');
     80 set(get(gca,'XLabel'),'VerticalAlignment','top');
     81 
     82 
     83 % Shrink the axes to keep labels from being cut off:
     84 % See              The MathWorks MATLAB Digest
     85 %                   June 1995
     86 %              Volume 3, number 6
     87 
     88 pos = get(gca,'position'); 		% This is in normalized coordinates
     89 pos(3:4)=pos(3:4)*shrinkfactor; 	% Shrink the axis by a factor of .9
     90 pos(1:2)=pos(1:2)+pos(3:4)*(1-shrinkfactor); % Center it in the figure window
     91 set(gca,'position',pos);
     92 
     93 set(gca,'Box','off');
     94 
     95 if dowait;
     96    wait('Adjust any figure settings you want and press Enter');
     97 end;
     98 
     99 
    100 % Now we turn off the axis labels:
    101 set(gca,'XTick',[]);
    102 set(gca,'YTick',[]);
    103 
    104 refresh;
    105