Patch not working properly with 2d latitude and longitude
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
Voss
2022년 5월 17일
Try using surface instead of patch.
댓글 수: 6
Voss
2022년 5월 17일
편집: Voss
2022년 5월 17일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!