Home > omviz > gregaxd.m

gregaxd

PURPOSE ^

GREGAXD Labels the current x-axis with Gregorian labels in units of days,

SYNOPSIS ^

function []=gregaxd(jd,daytic);

DESCRIPTION ^

 GREGAXD Labels the current x-axis with Gregorian labels in units of days,
      GREGAXD(JD,DAYTIC) draws Gregorian time labels on the x-axis in
      intervals of DAYTIC days.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function []=gregaxd(jd,daytic);
0002 % GREGAXD Labels the current x-axis with Gregorian labels in units of days,
0003 %      GREGAXD(JD,DAYTIC) draws Gregorian time labels on the x-axis in
0004 %      intervals of DAYTIC days.
0005 
0006 % Rich Signell
0007 
0008 monstr=['Jan';'Feb';'Mar';'Apr';'May';'Jun';'Jul';'Aug';'Sep';...
0009 'Oct';'Nov';'Dec'];
0010 
0011 n=length(jd);
0012 jd0=floor(jd(1));
0013 jd1=ceil(jd(n));
0014 %xlim=[jd0-.5 jd1+.5];
0015 %set(gca,'xlim',xlim);
0016 jdtic=[jd0:daytic:jd1]';
0017 greg=gregorian(jdtic);
0018 %
0019 % find day labels
0020 %
0021 day=greg(:,3);
0022 dayticlab=sprintf('%2d',day);
0023 nday=length(day);
0024 dayticlab=reshape(dayticlab,2,nday)';
0025 set(gca,'xtick',jdtic,'Xticklabels',dayticlab)
0026 %
0027 % find month labels
0028 %
0029 mon=greg(:,2);
0030 mondiff=diff(mon);
0031 ind=[1 ; find(mondiff~=0)+1];
0032 montic=jdtic(ind)';
0033 %
0034 % find year labels
0035 %
0036 year=greg(:,1);
0037 yeardiff=diff(year);
0038 year_ind=[1 ; find(yeardiff~=0)+1];
0039 yeartic=jdtic(year_ind)';
0040 
0041 % determine y location of month and year labels by determining
0042 % the font height for the day labels, separating the lines
0043 % by linesep pixels
0044 %
0045 linesep=8;
0046 ylim=get(gca,'ylim');   %y position of x axis in user units
0047 set(gca,'units','pixels'); 
0048 pos=get(gca,'pos');
0049 ymin=pos(2);            % y position of x axis in pixels
0050 fontsize=get(gca,'fontsize');    %fontsize = height in pixels?
0051 set(gca,'units','normalized');
0052 ytop=ymin-(fontsize+linesep);    %y location of top of month labels in pixels
0053 ytopm=ylim(1)-(ymin-ytop)*(ylim(2)-ylim(1))/pos(4); % " ", but in user units
0054 ytopy=ytopm-(fontsize+linesep)*(ylim(2)-ylim(1))/pos(4);
0055 %
0056 % label months
0057 %
0058 for i=1:length(mon(ind));
0059   monticlab(i,:)=monstr(mon(ind(i)),:);
0060   text(montic(i),ytopm,monticlab(i,:),...
0061     'HorizontalAlignment','center',...
0062     'VerticalAlignment','top','fontsize',fontsize);
0063 end
0064 %
0065 % label years
0066 %
0067 for i=1:length(year(year_ind));
0068   yearticlab(i,:)=int2str(year(year_ind(i)));
0069   text(yeartic(i),ytopy,yearticlab(i,:),...
0070      'HorizontalAlignment','center',...
0071      'VerticalAlignment','top','fontsize',fontsize);
0072 end

Generated on Thu 01-Dec-2005 08:50:35 by m2html © 2003