Plotting time in x-axis
2 views (last 30 days)
Show older comments
Hi,
I'm trying to plot 2 hydrographs for comparison but I'm having problems with changing the time in the x axis to the format of Hour in the day like "DD HH:MM". The code I'm using to plot is shown below. I've tried datetick with no luck. Thank you for your help!
plot(dateus(z1:z2),Qusgs(z1:z2),'m');
hold on
plot(ns,Q,'g');
hold off
legend('USGS','SWMM')
title('Change in Width for Accotink Watershed Using Dulles Precipitation Data for Sept29-Oct2, 2010 Event')
xlabel('Time')
ylabel('Q')
saveas(h,sprintf('Width%d.png',x));
3 Comments
dpb
on 7 Nov 2013
Edited: dpb
on 8 Nov 2013
OK, so still what/how does the dateus value relate to real time? You'll need to translate that to Matlab datenum as noted earlier to use builtin Matlab facilities. Otherwise, you can manually make labels but that's the harder solution it would seem.
ADDENDUM:
Matlab thinks 733779 is 6Jan2009 if assume a datenum -- is this correct? Excel thinks its 6Jan3909 owing to the difference in start dates.
Whatever it is, that's the basic starting point to get the offset from the Matlab datenum origin to match up to what these represent if they're not Matlab-consistent as is. If they are, then plot with them on the x-axis and as noted, used datetick to format the axis as desired.
Answers (1)
dpb
on 7 Nov 2013
You need the x-axis variables to be in Matlab serial datenums and then used datetick to format.
doc datenum % and friends
doc datetick
0 Comments
See Also
Categories
Find more on Dates and Time in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!