Patch not working properly with 2d latitude and longitude
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
MICHELE GNESOTTO
am 16 Mai 2022
Bearbeitet: Voss
am 17 Mai 2022
Hi all,
i am trying to plot the sea surface temperature from a netcdf file. when i upload it , i have this
i tried to use patch in this way
patch(longitude ,latitude , mean(tos,3,'omitnan') , 'FaceColor','interp', 'EdgeColor' , 'interp' )
but the results is not good , i have temperature over the land , so i think something is wrong with my grid, but
I can't understand why. If you have any suggestion to help I would very appreciate it.
Thanks
Michele
0 Kommentare
Akzeptierte Antwort
Voss
am 17 Mai 2022
Try using surface instead of patch.
6 Kommentare
Voss
am 17 Mai 2022
Bearbeitet: Voss
am 17 Mai 2022
Here it is using latitude and longitude. It appears to have better proportions now.
[The longitude goes from 72.5 up to 360 then wraps around back to 0 and up to 73.5, but there is a little dip around 271 where it decreases for one sample, so to try to get it right, I find where there is the big decrease from 360 to 0 and add 360 to samples after that, so that from beginning to end it's ~72.5 to ~433.5. Then I label the xticks with mod(longitude,360). I'm sure you can get something better with stuff from the mapping toolbox, if you have it.]
unzip('adaptor.esgf_wps.retrieve-1652740104.757926-1767-15-d7ea9cac-5f2f-4b52-9b1f-0ba84ab0122b.zip')
longitude = ncread('tos_Omon_CMCC-ESM2_ssp585_r1i1p1f1_gn_21000116-21000116_v20210126.nc','longitude');
latitude = ncread('tos_Omon_CMCC-ESM2_ssp585_r1i1p1f1_gn_21000116-21000116_v20210126.nc','latitude');
tos = ncread('tos_Omon_CMCC-ESM2_ssp585_r1i1p1f1_gn_21000116-21000116_v20210126.nc','tos');
longitude = longitude(:,1);
disp([longitude(195:205) [NaN; diff(longitude(195:205))]]);
idx = find(diff(longitude) < -350,1);
longitude(idx+1:end) = 360+longitude(idx+1:end);
figure();
surface(longitude(:,1),latitude(1,:),tos.', ...
'FaceColor','interp', ...
'EdgeColor','interp');
axis equal
xticklabels(sprintfc('%d',mod(xticks(),360)))
Regarding plotting coastlines, I'm not sure.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Lighting, Transparency, and Shading 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!