reverse-shooting

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

PlotAxisAtOrigin.m (1131B)


      1 function PlotAxisAtOrigin(x,y);
      2 %PlotAxisAtOrigin Plot 2D axes through the origin
      3 %   This is a 2D version of Plot3AxisAtOrigin written by Michael Robbins
      4 %   File exchange ID: 3245. 
      5 %
      6 %   Have hun! 
      7 %
      8 %   Example:
      9 %   x = -2*pi:pi/10:2*pi;
     10 %   y = sin(x);
     11 %   PlotAxisAtOrigin(x,y)
     12 %
     13 % Downloaded from   5/29/08
     14 %  http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=10473&objectType=file
     15 
     16 % PLOT
     17 if nargin == 2 
     18     plot(x,y);
     19     hold on;
     20 else
     21     display('   Not 2D Data set !')
     22 end;
     23 
     24 % GET TICKS
     25 X=get(gca,'Xtick');
     26 Y=get(gca,'Ytick');
     27 
     28 % GET LABELS
     29 XL=get(gca,'XtickLabel');
     30 YL=get(gca,'YtickLabel');
     31 
     32 % GET OFFSETS
     33 Xoff=diff(get(gca,'XLim'))./40;
     34 Yoff=diff(get(gca,'YLim'))./40;
     35 
     36 % DRAW AXIS LINEs
     37 plot(get(gca,'XLim'),[0 0],'k');
     38 plot([0 0],get(gca,'YLim'),'k');
     39 
     40 % Plot new ticks  
     41 for i=1:length(X)
     42     plot([X(i) X(i)],[0 Yoff],'-k');
     43 end;
     44 for i=1:length(Y)
     45    plot([Xoff, 0],[Y(i) Y(i)],'-k');
     46 end;
     47 
     48 % ADD LABELS
     49 text(X,zeros(size(X))-2.*Yoff,XL);
     50 text(zeros(size(Y))-3.*Xoff,Y,YL);
     51 
     52 box off;
     53 % axis square;
     54 axis off;
     55 set(gcf,'color','w');
     56