Filter löschen
Filter löschen

Non numerical axis marks

4 Ansichten (letzte 30 Tage)
Dany
Dany am 15 Aug. 2012
hi, im trying to make a plot in which i have numeric data with a coresponding date for each data point. how can i make the marks on the X axis to be the dates. the format of the date is "01/01/2012", for example, and it have to stay that way. i have it in a string array or cell array. is it possible ? thank you.

Antworten (1)

Oleg Komarov
Oleg Komarov am 15 Aug. 2012
Yes, you can do that in several ways:
d = {'01/01/2012','02/01/2012','03/01/2012','04/01/2012','05/01/2012'};
1st method using datetick with serial dates (I recommend this)
dnum = datenum(d,'dd/mm/yyyy');
plot(dnum, 1:5);
datetick('x','dd/mm/yyyy')
2nd method manually set ticks
plot(1:5)
set(gca,'Xtick',1:5,'XtickL',d)

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by