Fixing missing part of a figure from a plot
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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);
0 commentaires
Réponses (1)
Voss
le 25 Août 2023
Your xlim stop at 2022-07-15 23:59:59. Set it to 2022-07-16 00:00:00 instead.
0 commentaires
Voir également
Catégories
En savoir plus sur Dates and Time dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!