What would be the best way to handle matlab time format with pgfplots? I have understood that pgfdateplot can only handle well yyyy.mm.dd HH:MM format but not seconds and especially nothing beyond that. How to plot data in yyyy.mm.dd HH:MM:SS.SSS format, but read it from the file that is in the matlab format:


There is one answer in question pgfplots data time format, but I'm not sure how to apply it to this situation.

  • pgfplots can't handle seconds in datetimes, so I'd suggest making a vector of decimal seconds (t2 = datevec(time-time(1));t2=t2(:,6);) and having seconds on the x-axis. Describe in the caption that it is seconds starting at HH:MM:SS.SSS on dd.mm.yyyy. – Torbjørn T. Aug 24 '16 at 21:25
  • Has the comment of TorbjørnT. helped you to find a suitable solution? – Stefan Pinnow Oct 9 '16 at 14:02
  • @StefanPinnow it was not exactly what I was looking for but maybe there is no way to achive what I wanted – Lesenger Oct 9 '16 at 15:53

This might well be possible with pgfplots, but it's likely easier to make a new time vector in Matlab that contains the number of seconds from time zero. E.g. in Matlab do t2 = datevec(time-time(1));t2=t2(:,6);, where time is the name of your original time vector. Then you can describe in the caption and/or xlabel that the x-coordinate is seconds after HH:MM:SS.SS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.