


GREGAXIS Convert numeric XTickLabels to date strings.
GREGAXIS gets the x-axis tick values from the current axis
and converts them to date strings of the form "Jan 1 ",
"Feb 27", ... The value 1 maps to "Jan 1 ", and the
value 365 maps to "Dec 31". Labels for values outside
this range are blank.
Limitations: GREGAXIS doesn't know about leap year.
GREGAXIS only knows how to label days with respect to the
first day of the year; it can't label days with respect
to some absolute date.
Example:
plot(1:10:365, 1:10:365)
gregor

0001 %GREGAXIS Convert numeric XTickLabels to date strings. 0002 % GREGAXIS gets the x-axis tick values from the current axis 0003 % and converts them to date strings of the form "Jan 1 ", 0004 % "Feb 27", ... The value 1 maps to "Jan 1 ", and the 0005 % value 365 maps to "Dec 31". Labels for values outside 0006 % this range are blank. 0007 % 0008 % Limitations: GREGAXIS doesn't know about leap year. 0009 % GREGAXIS only knows how to label days with respect to the 0010 % first day of the year; it can't label days with respect 0011 % to some absolute date. 0012 % 0013 % Example: 0014 % plot(1:10:365, 1:10:365) 0015 % gregor 0016 0017 0018 0019 months = [1 cumsum([31 28 31 30 31 30 31 31 30 31 30 31])+1]'; 0020 monthsTable = [months (1:13)']; 0021 monthStr = ['Jan' 0022 'Feb' 0023 'Mar' 0024 'Apr' 0025 'May' 0026 'Jun' 0027 'Jul' 0028 'Aug' 0029 'Sep' 0030 'Oct' 0031 'Nov' 0032 'Dec']; 0033 0034 ticks = get(gca, 'XTick'); 0035 ticks=rem(ticks,365); 0036 newTickLabels = zeros(length(ticks), 6); 0037 for k = 1:length(ticks) 0038 if ((ticks(k) > 0) & (ticks(k) < 366)) 0039 month = floor(table1(monthsTable, ticks(k))); 0040 day = ticks(k) - months(month) + 1; 0041 newTickLabels(k,:) = sprintf('%s %-2d', monthStr(month,:), day); 0042 else 0043 newTickLables(k,:) = ' '; 0044 end 0045 end 0046 set(gca, 'XTickLabels', newTickLabels);