preserve datetick labels when resizing

조회 수: 3 (최근 30일)
Hugh
Hugh 2011년 12월 27일
"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.
Thanks, Hugh

답변 (3개)

owr
owr 2012년 1월 4일
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
Walter Roberson 2011년 12월 29일
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.
  댓글 수: 2
Hugh
Hugh 2011년 12월 29일
Thanks Walter. I am not familiar on these commands. Could you tell specifically what I can do? Yes, it is not resized, it is zoomed when the Matlab fig was exported to PowerPoint.
Walter Roberson
Walter Roberson 2011년 12월 29일
http://www.mathworks.com/matlabcentral/newsreader/view_thread/236459
http://www.mathworks.com/matlabcentral/fileexchange/15029-datetickzoom-automatically-update-dateticks
http://www.mathworks.com/matlabcentral/newsreader/view_thread/288445

댓글을 달려면 로그인하십시오.


Patrick Kalita
Patrick Kalita 2011년 12월 29일
Here's a small example that might help:
function test
plot( now : now+30, rand( 1, 31 ) );
datetick x;
set( gca, 'Tag', 'dateAxes' );
set( gcf, 'ResizeFcn', @resize );
function resize(src, evt)
ax = findall( src, 'Tag', 'dateAxes' );
datetick( ax, 'x' );
  댓글 수: 3
Hugh
Hugh 2012년 1월 3일
Any way to attached a small data file?
Walter Roberson
Walter Roberson 2012년 1월 3일
http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by