Home > timeplt > gregaxh.m

gregaxh

PURPOSE ^

GREGAXH Labels the current x-axis with Gregorian labels in units of hours,

SYNOPSIS ^

function []=gregaxh(jd,hourtic);

DESCRIPTION ^

 GREGAXH Labels the current x-axis with Gregorian labels in units of hours,
      GREGAXH(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 []=gregaxh(jd,hourtic);
0002 % GREGAXH Labels the current x-axis with Gregorian labels in units of hours,
0003 %      GREGAXH(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 
0020 start=[start(1:4) 0 0];
0021 stop=[stop(1:3) stop(4)+1 0 0];
0022 jd0=julian(start);
0023 jd1=julian(stop);
0024 jdtic=[jd0:hourtic/24:jd1]';
0025 greg=gregorian(jdtic);
0026 %xlim=[jd0-1/48 jd1+1/48];
0027 %set(gca,'xlim',xlim);
0028 %
0029 % find hour labels
0030 %
0031 hour=greg(:,4);
0032 min=greg(:,5);
0033 hourticlab=sprintf('%2.2d:%2.2d',[hour min]');
0034 nhour=length(hour);
0035 hourticlab=reshape(hourticlab,5,nhour)';
0036 set(gca,'xtick',jdtic,'Xticklabels',hourticlab)
0037 %
0038 % find month and day labels
0039 %
0040 mon=greg(:,2);
0041 day=greg(:,3);
0042 daydiff=diff(day);
0043 ind=[1 ; find(daydiff~=0)+1];
0044 daytic=jdtic(ind)';
0045 %
0046 % find year labels
0047 %
0048 year=greg(:,1);
0049 yeardiff=diff(year);
0050 year_ind=[1 ; find(yeardiff~=0)+1];
0051 yeartic=jdtic(year_ind)';
0052 
0053 % determine y location of month and year labels by determining
0054 % the font height for the day labels, separating the lines
0055 % by linesep pixels
0056 %
0057 linesep=8;
0058 ylim=get(gca,'ylim');   %y position of x axis in user units
0059 set(gca,'units','pixels'); 
0060 pos=get(gca,'pos');
0061 ymin=pos(2);            % y position of x axis in pixels
0062 fontsize=get(gca,'fontsize');    %fontsize = height in pixels?
0063 set(gca,'units','normalized');
0064 ytop=ymin-(fontsize+linesep);    %y location of top of month labels in pixels
0065 ytopm=ylim(1)-(ymin-ytop)*(ylim(2)-ylim(1))/pos(4); % " ", but in user units
0066 ytopy=ytopm-(fontsize+linesep)*(ylim(2)-ylim(1))/pos(4);
0067 %
0068 % label day and month
0069 %
0070 for i=1:length(mon(ind));
0071   monticlab(i,:)=monstr(mon(ind(i)),:);
0072   text(daytic(i),ytopm,...
0073     [monticlab(i,:) ' ' int2str(day(ind(i)))],...
0074     'HorizontalAlignment','center',...
0075     'VerticalAlignment','top','fontsize',fontsize);
0076 end
0077 %
0078 % label years
0079 %
0080 for i=1:length(year(year_ind));
0081   yearticlab(i,:)=int2str(year(year_ind(i)));
0082   text(yeartic(i),ytopy,yearticlab(i,:),...
0083      'HorizontalAlignment','center',...
0084      'VerticalAlignment','top','fontsize',fontsize);
0085 end

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