reverse-shooting

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

MoveAxisToOrigin.m (1618B)


      1 % MoveAxisToOrigin.m  5/29/08
      2 %   Copied from PlotAxisAtOrigin(x,y);
      3 %
      4 %   Let's you create the plot, change labels, etc. and then call this
      5 %   at the last step to move the axes to the right place.
      6 
      7 %function 
      8 %PlotAxisAtOrigin Plot 2D axes through the origin
      9 %   This is a 2D version of Plot3AxisAtOrigin written by Michael Robbins
     10 %   File exchange ID: 3245. 
     11 %
     12 %   Have hun! 
     13 %
     14 %   Example:
     15 %   x = -2*pi:pi/10:2*pi;
     16 %   y = sin(x);
     17 %   PlotAxisAtOrigin(x,y)
     18 %
     19 % Downloaded from   5/29/08
     20 %  http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=10473&objectType=file
     21 
     22 % Chad: All I did is comment this out...
     23 % PLOT
     24 %if nargin == 2 
     25 %    plot(x,y);
     26 %    hold on;
     27 %else
     28 %    display('   Not 2D Data set !')
     29 %end;
     30 
     31 % GET TICKS
     32 X=get(gca,'Xtick');
     33 Y=get(gca,'Ytick');
     34 
     35 % GET LABELS
     36 XL=get(gca,'XtickLabel');
     37 YL=get(gca,'YtickLabel');
     38 
     39 % GET OFFSETS
     40 Xoff=diff(get(gca,'XLim'))./40;
     41 Yoff=diff(get(gca,'YLim'))./40;
     42 
     43 % DRAW AXIS LINEs
     44 plot(get(gca,'XLim'),[0 0],'k','LineWidth',1);
     45 plot([0 0],get(gca,'YLim'),'k','LineWidth',1);
     46 
     47 % Plot new ticks  
     48 for i=1:length(X)
     49     plot([X(i) X(i)],[0 Yoff],'-k','LineWidth',1);
     50 end;
     51 for i=1:length(Y)
     52    plot([Xoff, 0],[Y(i) Y(i)],'-k','LineWidth',1);
     53 end;
     54 
     55 % ADD LABELS
     56 if ~isempty(X);
     57   text(X,zeros(size(X))-2.*Yoff,XL);
     58 end;
     59 if ~isempty(Y);
     60   text(zeros(size(Y))-3.*Xoff,Y,YL);
     61 end;
     62 
     63 box off;
     64 % axis square;
     65 axis off;
     66 set(gcf,'color','w');
     67 
     68 % Fix Visibility of XLabel and YLabel
     69 hx=get(gca,'XLabel');
     70 set(hx,'Visible','on');
     71 hy=get(gca,'YLabel');
     72 set(hy,'Visible','on');
     73 
     74 %keyboard