How to compress x-axis with datetime values so that only the times with datapoints are displayed?
3 次查看(过去 30 天)
显示 更早的评论
Dear all,
I am having issues with plotting data over datetime. The dataset cointains data from the 19.10.2016 11pm UTC - 20.10.2016 08pm UTC. However, plotting the data with
time = datetime(data.Time_UTC, 'InputFormat', 'HH:mm:ss');
date = datetime(data.Date, 'InputFormat', 'dd-MM-yyyy');
Datetime = date + timeofday(time);
figure;
subplot(3,2,1);plot(datenum(Datetime),evap,'.');xlabel('time');ylabel('Evap (mm/h)');grid;datetick('x', 'yyyy-mm-dd')%title(['Ts= ' num2str(ts(1)) ' Ta= ' num2str(t(1)) ' RH= ' num2str(rh(1)) ' Wave Age= ' num2str(Wa(1))]);
subplot(3,2,2);plot(datenum(Datetime),ebulk,'.');xlabel('time');ylabel('Evap (mm/h)');grid;datetick('x', 'yyyy-mm-dd')%title(['Ts= ' num2str(ts(1)) ' Ta= ' num2str(t(1)) ' RH= ' num2str(rh(1)) ' Wave Age= ' num2str(Wa(1))]);
subplot(3,2,3);area(datenum(Datetime),evap_acm);xlabel('time');ylabel('Evap acm (mm)');grid;datetick('x', 'yyyy-mm-dd')
subplot(3,2,4);area(datenum(Datetime),ebulk_acm);xlabel('time');ylabel('Evap acm (mm)');grid;datetick('x', 'yyyy-mm-dd')
subplot(3,2,5);plot(datenum(Datetime),shflux,'.');xlabel('time');ylabel('Sensible Heat Flux (W/m^2)');grid;datetick('x', 'yyyy-mm-dd')
subplot(3,2,6);plot(datenum(Datetime),lhflux,'.');xlabel('time');ylabel('Latent Heat Flux (W/m^2)');grid;datetick('x', 'yyyy-mm-dd')
leads to this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/747309/image.jpeg)
but I actually want only the Data which actually contains data - can anyone help?
Thanks in advance!!
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!