MATLAB: How to make a stacked area chart , where x axis is the datetime variable

stacked area chart

I am learning how to draw graphs in Matlab.
I have a problem making stacked area chart. I would like to have on x axis the time and I have the time numbers as my first column of Y matrix, in datenum format. Like this:
Y = [730301, 1, 5, 3;
730302, 3, 2, 7;
730303,1, 5, 3;
730304,2, 6, 1];
If I exclude first column, which are my dates, I can easily plot by:
Y = [1, 5, 3; 3, 2, 7; 1, 5, 3; 2, 6, 1]; figure area(Y)
However, then x axis is not the one I need, and when I am trying to adjust it does not provide a correct view.
this works:
area(y(:,1), y(:,2:end))
However, i want my dates to be in yearly manner represented in graph and not datenum. What to do?

Best Answer

Use the datetick (link) function:
Y = [730301, 1, 5, 3;
730302, 3, 2, 7;
730303,1, 5, 3;
730304,2, 6, 1];
figure(1)
area(Y(:,1), Y(:,2:end))
datetick('x', 'yyyy-mm-dd')
See the documentation on datetick for more options and formats.
Related Question