Home > timeplt > gregaxmi.m

gregaxmi

PURPOSE ^

GREGAXMI Labels the x-axis with Gregorian labels in units of minutes,

SYNOPSIS ^

function []=gregaxmi(jd,hourtic);

DESCRIPTION ^

 GREGAXMI Labels the x-axis with Gregorian labels in units of minutes,
     GREGAXMI(JD,HOURTIC) draws Gregorian time labels on the x-axis in
     intervals of HOURTIC hours.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function []=gregaxmi(jd,hourtic);
0002 % GREGAXMI Labels the x-axis with Gregorian labels in units of minutes,
0003 %     GREGAXMI(JD,HOURTIC) draws Gregorian time labels on the x-axis in
0004 %     intervals of HOURTIC hours.
0005 monstr=['Jan';'Feb';'Mar';'Apr';'May';'Jun';'Jul';'Aug';'Sep';...
0006 'Oct';'Nov';'Dec'];
0007 
0008 n=length(jd);
0009 
0010 jd0_index = find(jd == gmin(jd));
0011 jd0=jd(jd0_index(1));
0012 
0013 jdn_index = find(jd == gmax(jd));
0014 n = length(jdn_index);
0015 jdn=jd(jdn_index(n));
0016 
0017 [start]=gregorian(jd0);
0018 [stop]=gregorian(jdn);
0019 start=[start(1:5) 0];
0020 stop=[stop(1:4) stop(5)+1 0];
0021 
0022 jd0=julian(start);
0023 jd1=julian(stop);
0024 
0025 %
0026 % expect hourtic to be between 1 and 6
0027 jdtic=[jd0:hourtic/(24*60):jd1]';    % tic every min
0028 greg=gregorian(jdtic);
0029 
0030 %xlim=[jd0-1/(24*60) jd1+1/(24*60)];
0031 %set(gca,'xlim',xlim);
0032 
0033 %
0034 % find minute:second labels
0035 %
0036 min=greg(:,5);
0037 sec=greg(:,6);
0038 minticlab=sprintf('%2.2d:%2.2d',[min sec]');
0039 nmin=length(min);
0040 minticlab=reshape(minticlab,5,nmin)';
0041 set(gca,'xtick',jdtic,'Xticklabels',minticlab)
0042 
0043 %
0044 % find hour labels
0045 %
0046 %hour=greg(:,4);
0047 %min=greg(:,5);
0048 %hourticlab=sprintf('%2.2d:%2.2d',[hour min]');
0049 %nhour=length(hour);
0050 %hourticlab=reshape(hourticlab,5,nhour)';
0051 %set(gca,'xtick',jdtic,'Xticklabels',hourticlab)
0052 %
0053 % find hour labels
0054 %
0055 hr=greg(:,4);
0056 hrdiff=diff(hr);
0057 ind=[1 ; find(hrdiff~=0)+1];
0058 hrtic=jdtic(ind)';
0059 
0060 
0061 
0062 %
0063 % find month and day labels
0064 %
0065 mon=greg(:,2);
0066 day=greg(:,3);
0067 daydiff=diff(day);
0068 ind=[1 ; find(daydiff~=0)+1];
0069 daytic=jdtic(ind)';
0070 
0071 
0072 %
0073 % find year labels
0074 %
0075 year=greg(:,1);
0076 yeardiff=diff(year);
0077 year_ind=[1 ; find(yeardiff~=0)+1];
0078 yeartic=jdtic(year_ind)';
0079 
0080 
0081 % determine y location of month and year labels by determining
0082 % the font height for the day labels, separating the lines
0083 % by linesep pixels
0084 %
0085 linesep=8;
0086 ylim=get(gca,'ylim');   %y position of x axis in user units
0087 set(gca,'units','pixels'); 
0088 pos=get(gca,'pos');
0089 ymin=pos(2);            % y position of x axis in pixels
0090 fontsize=get(gca,'fontsize');    %fontsize = height in pixels?
0091 set(gca,'units','normalized');
0092 ytop=ymin-(fontsize+linesep);    %y location of top of month labels in pixels
0093 ytopm=ylim(1)-(ymin-ytop)*(ylim(2)-ylim(1))/pos(4); % " ", but in user units
0094 ytopy=ytopm-(fontsize+linesep)*(ylim(2)-ylim(1))/pos(4);
0095 
0096 
0097 
0098 %
0099 % label day and month
0100 %
0101 for i=1:length(mon(ind));
0102   monticlab(i,:)=monstr(mon(ind(i)),:);
0103   tptr=text(daytic(i),ytopm,...
0104     [monticlab(i,:) ' ' int2str(day(ind(i))) ' ' int2str(hr(ind(i))) ':00' ],...
0105     'HorizontalAlignment','center',...
0106     'VerticalAlignment','top','fontsize',fontsize);
0107   set(tptr,'units','normalized');
0108 end
0109 
0110 
0111 
0112 %
0113 % label years
0114 %
0115 for i=1:length(year(year_ind));
0116   yearticlab(i,:)=int2str(year(year_ind(i)));
0117   tptr=text(yeartic(i),ytopy,yearticlab(i,:),...
0118      'HorizontalAlignment','center',...
0119      'VerticalAlignment','top','fontsize',fontsize);
0120   set(tptr,'units','normalized');
0121 end

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