Make contour plot with z values against year in x-axis and Date in y-axis?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a CSV file with temperature values. The temperature values are for each day of june month from 1990-2020. See the attached file. I am plotting a contour plot of temperature values against year and day with years in x-axis and day in y-axis. Kindly help me out. Thanks in advance!
0 Kommentare
Antworten (1)
Manish
am 4 Okt. 2024
Hi,
I understand you want to contour plot of the temperature where years on the x-axis and day on y-axis and temperature on the z-axis.
Here is the code implementation :
data = readtable('mean_temp_june1.csv');
% Convert the date column to datetime format using the correct format
dates = datetime(data.date, 'InputFormat', 'dd-MM-yyyy');
data.date = dates;
data.day = day(data.date);
unique_years = unique(data.year);
unique_days = unique(data.day);
% Create a matrix for temperature data
temp_matrix = NaN(length(unique_days), length(unique_years));
% Fill the matrix with temperature values
for i = 1:height(data)
day_index = find(unique_days == data.day(i));
year_index = find(unique_years == data.year(i));
temp_matrix(day_index, year_index) = data.temp_min(i);
end
% Create the contour plot
figure;
contour(unique_years, unique_days, temp_matrix, 'LineColor', 'none');
colorbar;
% Add labels and title
xlabel('Year');
ylabel('Day of June');
title('Contour Plot of Temperature Values (June 1990-2020)');
% Display the plot
grid on;
Hope this solves!Happy coding!!
0 Kommentare
Siehe auch
Kategorien
Mehr zu Language Fundamentals finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!