Fixing missing part of a figure from a plot

조회 수: 6 (최근 30일)
Tunde Adubi
Tunde Adubi 2023년 8월 25일
답변: Voss 2023년 8월 25일
After making a plot, the x-axis does not show all timestamp for 24 hrs period in the figure. See the image attached.
How can the 24th hour be included?
% Loop through each file
for idx = 1:120
% Full path to the netCDF file
ncFile = fullfile(fileList(idx).folder, fileList(idx).name);
% Extract timestamp from filename for plotting
timeStr = fileList(idx).name(19:24); % extracting HHMMSS from filename
% Convert to datetime for plotting
timestamps(idx) = datetime(['2022-07-15 ', timeStr(1:2), ':', timeStr(3:4), ':', timeStr(5:6)], 'InputFormat', 'yyyy-MM-dd HH:mm:ss');
end
% Plotting the time series
figure('position',[100 100 700 350]);
hold on
plot(timestamps, reflectivityData, '-k','LineWidth',1.0)
xlabel('Time (UTC)', 'FontSize',10);
ylabel('Corrected Reflectivity (dBZ)','FontSize',10);
set(gca,'ylim', [-10 50], 'fontsize', 10)
% Define specific timestamps for x-ticks
desiredTicks = datetime(2022, 7, 15, 0:1:24, 0, 0); % From 00:00 to 24:00 every 1 hours
% Set the x-ticks to the desired timestamps
xticks(desiredTicks);
xlim([datetime('2022-07-15 00:00:00', 'InputFormat', 'yyyy-MM-dd HH:mm:ss'), datetime('2022-07-15 23:59:59', 'InputFormat', 'yyyy-MM-dd HH:mm:ss')]);
title('Time Series of Corrected Z | 07-15 | ', 'FontSize',10);
grid on;
xtickangle(60);

답변 (1개)

Voss
Voss 2023년 8월 25일
Your xlim stop at 2022-07-15 23:59:59. Set it to 2022-07-16 00:00:00 instead.

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by