On 4/16/2013 8:51 AM, Steven_Lord wrote: > "dpb" <email@example.com> wrote in message > news:firstname.lastname@example.org... >> On 4/16/2013 12:52 AM, PK wrote: >> ... >> >>> now I managed to get dates on x axis but it only shows the date not the >>> time. and the cursot tip still shows the number 7.~+005 with my data. >> >> doc datetick % specify format you want >> >> As for the cursor, don't know--there's a good possibility TMW hasn't >> implemented the conversion back to a date string from the datenum. >> >> doc datestr % to convert back >> >> Best I know is a callback routine that incorporates it but never tried >> it... > > You can specify a custom display function for use by data cursors. > > http://www.mathworks.com/help/matlab/ref/datacursormode.html > > See the second half of the Example for how to specify the UpdateFcn. > Instead of using NUM2STR as the Example does, you'd use DATESTR.
Ah, very good...thanks, Steven.
And, NB: if want time on the x-axis, you'll probably run out of room to display full date-time strings on the plot. Depending on how long your series is you may need to plot only the increasing portion of the datenums instead of the full number--ie, subtract dn(1) from the vector and plot it. Then use a time-only format string and text() to label a date manually, perhaps.
Have always thought datetick() needed some more smarts to be able to write 2-line labels to deal w/ the limited space available but afaik it doesn't (altho I didn't know for sure about the cursor mode, either... :) )