preserve datetick labels when resizing
8 views (last 30 days)
"datetick" prints dates on x-axis (e.g. "12/11/2011"), when the plot is resized, these dates are jammed together. How do I preserve the look?
Specicially I am printing the plot into powerpoint slides (using saveppt2.m from file exchange), the size changes, and I can't keep the same look.
owr on 4 Jan 2012
This doesnt relate exactly to your problem - but this is wonderful code that resets the date ticks when you zoom in/out of graph with a date axis. Perhaps you could learn something from the code that will help with your situation.
Walter Roberson on 29 Dec 2011
It is probably easier (or at least more cleanly isolated) to create a uipanel that you put the plot in, and then to use the ResizeFcn callback to detect the size change; the code in that callback would figure out the new ticks to use and set() the axes XTick property (and perhaps the XTickLabel as well.)
The uipanel step is not needed; you could instead use the ResizeFcn figure property.
But when you say resized, do you perhaps mean zoomed? If so then there is a different mechanism to use for that: for that set zoom mode and set the ActionPostCallback property to something that sets "nice" new ticks.
Patrick Kalita on 29 Dec 2011
Here's a small example that might help:
plot( now : now+30, rand( 1, 31 ) );
set( gca, 'Tag', 'dateAxes' );
set( gcf, 'ResizeFcn', @resize );
function resize(src, evt)
ax = findall( src, 'Tag', 'dateAxes' );
datetick( ax, 'x' );