Watch this Author's files
Peter: Many thanks for providing this much-needed routine. I use it all the time & it makes plots much more professional-looking.
I have two suggestions for small improvements:
1) Within the "if write_another_line" section, change to this to automatically sense if y-axes are reversed:
% Allow for reverse-direction y-axes. offset = .25 * abs(ylims(2)-ylims(1)) / yaxlinch; if strcmp(get(gca, 'YDir'), 'normal') yy = ylims(1) - offset; else yy = ylims(2) + offset; end
2) Add a 'Tag' to the "additional" text line, so that it is erased when dateNtick is called a second time on the same plot:
> Change the creation of text to this: text(xt-xlen, ypos, labels, ... 'Color', get(gca, 'XColor'), ... 'FontSize', get(gca, 'FontSize'), ... 'Tag', 'dateNtick_labels');
> Add this to beginning of function. % Get rid of old labels. delete(findobj('Parent', gca, ... 'Tag', 'dateNtick_labels'));
Much needed! Thanks!
Contact us at files@mathworks.com