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

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