Fixing missing part of a figure from a plot

4 views (last 30 days)
Tunde Adubi
Tunde Adubi on 25 Aug 2023
Answered: Voss on 25 Aug 2023
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);

Answers (1)

Voss
Voss on 25 Aug 2023
Your xlim stop at 2022-07-15 23:59:59. Set it to 2022-07-16 00:00:00 instead.

Categories

Find more on Polar Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!