Plotting time series data but data rounding to minute

Hi there,
I am plotting some time series data with the time data formatted as follows; '13/04/2018 01:00:49' However when I plot the data, it is appearing as per the attached image where all the data points appear to rounded to nearest minute ( or just the minute is plotted)
Anyone else come across this?
Thanks
Jack

댓글 수: 7

Jack, could you please attach the image?
oops sorry - thanks for highlighting. Please find attached
Paolo
Paolo 2018년 5월 29일
편집: Paolo 2018년 5월 29일
Try the following if you want to display full datetime:
plot(x,y);
h1 = gcf;
h1.Children.XAxis.TickLabelFormat = 'dd/MM/yyyy HH:mm:ss'
Thanks for you reply - unfortunately I am getting the error that the value is not a supported tick label format specification.
Paolo
Paolo 2018년 5월 29일
편집: Paolo 2018년 5월 29일
My apologies, the comment was not very clear. You must have a datetime array on the x axis. Try this:
dates = {'13/04/2018 01:00:49','13/04/2018 02:00:49','13/04/2018 03:00:49','13/04/2018 04:00:49'};
x = datetime(dates,'InputFormat','dd/MM/yyyy hh:mm:ss');
y = [1:4];
plot(x,y);
h1 = gcf;
h1.Children.XAxis.TickLabelFormat = 'dd/MM/yyyy HH:mm:ss';
I am using some random values for the x axis. Running on Matlab 2017b.
No worries, I understood - I have a datetime array on the x-axis already.
I tried your code but got the same error message. I am running 2016a - could that be the issue?
Paolo
Paolo 2018년 5월 29일
편집: Paolo 2018년 5월 29일
Could be, you can try different formats and see what format it accepts. If you only wish to display the hours and minutes with not rounded values, try the following:
h1.Children.XAxis.TickValues = x;
h1.Children.XAxis.TickLabelFormat = 'HH:mm:ss';

댓글을 달려면 로그인하십시오.

답변 (1개)

Peter Perkins
Peter Perkins 2018년 6월 4일

0 개 추천

Jack, what is it that makes you think all the data have been rounded to the nearest minute? Certainly the tick labels are rounded (and thinned to every 10min), but that's just the ticks, not the data.
Which are you concerned about? You should be able to zoom in to see where the actual data are plotted.

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

태그

질문:

2018년 5월 29일

답변:

2018년 6월 4일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by