Home > timeplt > 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 
0013 
0014 jd0_index = find(jd == gmin(jd));
0015 jd0=jd(jd0_index(1));
0016 
0017 jdn_index = find(jd == gmax(jd));
0018 n = length(jdn_index);
0019 jd1=jd(jdn_index(n));
0020 
0021 %xlim=[jd0-.5 jd1+.5];
0022 %set(gca,'xlim',xlim);
0023 jdtic=[round(jd0):daytic:round(jd1)]';
0024 %jdtic=[jd0:daytic:jd1]';
0025 greg=gregorian(jdtic);
0026 %
0027 % find day labels
0028 %
0029 day=greg(:,3);
0030 dayticlab=sprintf('%2d',day);
0031 nday=length(day);
0032 dayticlab=reshape(dayticlab,2,nday)';
0033 set(gca,'xtick',jdtic,'Xticklabels',dayticlab)
0034 %
0035 % find month labels
0036 %
0037 mon=greg(:,2);
0038 mondiff=diff(mon);
0039 ind=[1 ; find(mondiff~=0)+1];
0040 montic=jdtic(ind)';
0041 %
0042 % find year labels
0043 %
0044 year=greg(:,1);
0045 yeardiff=diff(year);
0046 year_ind=[1 ; find(yeardiff~=0)+1];
0047 yeartic=jdtic(year_ind)';
0048 
0049 % determine y location of month and year labels by determining
0050 % the font height for the day labels, separating the lines
0051 % by linesep pixels
0052 %
0053 linesep=8;
0054 ylim=get(gca,'ylim');   %y position of x axis in user units
0055 set(gca,'units','pixels'); 
0056 pos=get(gca,'pos');
0057 ymin=pos(2);            % y position of x axis in pixels
0058 fontsize=get(gca,'fontsize');    %fontsize = height in pixels?
0059 set(gca,'units','normalized');
0060 ytop=ymin-(fontsize+linesep);    %y location of top of month labels in pixels
0061 ytopm=ylim(1)-(ymin-ytop)*(ylim(2)-ylim(1))/pos(4); % " ", but in user units
0062 ytopy=ytopm-(fontsize+linesep)*(ylim(2)-ylim(1))/pos(4);
0063 %
0064 % label months
0065 %
0066 for i=1:length(mon(ind));
0067   monticlab(i,:)=monstr(mon(ind(i)),:);
0068   text(montic(i),ytopm,monticlab(i,:),...
0069     'HorizontalAlignment','center',...
0070     'VerticalAlignment','top','fontsize',fontsize);
0071 end
0072 %
0073 % label years
0074 %
0075 for i=1:length(year(year_ind));
0076   yearticlab(i,:)=int2str(year(year_ind(i)));
0077   text(yeartic(i),ytopy,yearticlab(i,:),...
0078      'HorizontalAlignment','center',...
0079      'VerticalAlignment','top','fontsize',fontsize);
0080 end

Generated on Wed 30-Nov-2005 15:41:21 by m2html © 2003