Plot empties after using datetick

2 visualizzazioni (ultimi 30 giorni)
Mohammad
Mohammad il 5 Apr 2013
Modificato: Joe Wildman il 21 Ott 2016
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 Commento
Joe Wildman
Joe Wildman il 21 Ott 2016
Modificato: Joe Wildman il 21 Ott 2016
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');

Accedi per commentare.

Risposta accettata

bym
bym il 5 Apr 2013
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');

Più risposte (0)

Categorie

Scopri di più su Dates and Time in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by