Plotting time in x-axis
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
dpb
le 7 Nov 2013
Modifié(e) : dpb
le 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.
Réponses (1)
dpb
le 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 commentaires
Voir également
Catégories
En savoir plus sur Dates and Time dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!