Plot empties after using datetick

조회 수: 4(최근 30일)
Mohammad
Mohammad 2013년 4월 5일
편집: Joe Wildman 2016년 10월 21일
I am trying to use datetick method to label one of the axes i have but when i use datetick, the ticks are displayed properly, but the plot area is cleared and plot vanishes. Here is a simplified example of what i am trying to do:
plot(rand(10));
startDate = datenum('01-01-2009');
endDate = datenum('12-31-2009');
xData = linspace(startDate,endDate,5);
set(gca,'XTick',xData);
datetick('x','dd-mmm','keepticks');
Any suggestions?
Thanks
  댓글 수: 1
Joe Wildman
Joe Wildman 2016년 10월 21일
편집: Joe Wildman 2016년 10월 21일
Try this:
startDate = datenum('01-01-2009');
endDate = datenum('12-31-2009');
xData = linspace(startDate,endDate,5);
plot(xData,rand(5));
set(gca,'XTick',xData);
datetick('x','dd-mmm','keepticks');

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

채택된 답변

bym
bym 2013년 4월 5일
clc;clear; close all
startDate = datenum('01-01-2009');
endDate = datenum('12-31-2009');
xData = linspace(startDate,endDate,10);% changed to match size of data
plot(xData,rand(10));
%set(gca,'XTick',xData); %maybe not necessary?
datetick('x','dd-mmm','keepticks');

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by