How to make a stacked area chart , where x axis is the datetime variable
8 views (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
Star Strider
on 8 Aug 2017
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.
0 Comments
More Answers (1)
See Also
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!