Fixing missing part of a figure from a plot
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!