필터 지우기
필터 지우기

M_map lambert projection

조회 수: 4 (최근 30일)
Bianka Markovic
Bianka Markovic 2021년 7월 2일
편집: Abhinaya Kennedy 2024년 6월 5일
Hello everyone, I'm trying to plot a lambert projection with my temperature data. First of all I plot data with was on a regular grid and everything went well. Then I interpolatet unregular data onto a regular grid I tried to plot it, but somehow it won't plot properly. Here an image for example. As you can see he detects the coastline properly but somehow don't leave them blank where the coast should be.
Maybe someone had a similar problem or has a suggestion why this keeps on happening. Thank you!!
for mon=12
%Nur ein monat temperature
m_proj('lambert','long',[-90 50],'lat',[45 85]);
disp('start plotting temp fesom')
h=figure;
ind=find(vq==0); vq(ind)=nan;
m_pcolor(Lon_oras,Lat_oras,vq(:,:,mon)); shading flat;
caxis([-2 10])
colormap;
cb=colorbar;
xlabel(cb,'Temperature');
m_grid('box','fancy','tickdir','in');
m_coast('patch',[.8 .8 .8],'edgecolor','k');
%title(['year: ',num2str(year),'; depth: ',num2str(depth),' m'],'fontsize',16);
print(h,'lambert_temperaturen_fesom_monat','-dpng');
end

답변 (1개)

Abhinaya Kennedy
Abhinaya Kennedy 2024년 6월 5일
편집: Abhinaya Kennedy 2024년 6월 5일
Hi Bianka,
The issue with your plot likely stems from how you are filling the missing data (NaN values) before plotting with "m_pcolor". Here's a possible solution:
Instead of setting all NaN values to zero with "vq(ind) = 0", you can use a masking technique to exclude them from the plotting process.
for mon = 12
% Nur ein monat temperature
m_proj('lambert','long',[-90 50],'lat',[45 85]);
disp('start plotting temp fesom')
h = figure;
% Mask out NaN values before plotting
mask = ~isnan(vq(:,:,mon));
m_pcolor(Lon_oras, Lat_oras, vq(:,:,mon), mask);
shading flat;
caxis([-2 10])
colormap;
cb = colorbar;
xlabel(cb,'Temperature');
m_grid('box','fancy','tickdir','in');
m_coast('patch',[.8 .8 .8],'edgecolor','k');
%title(['year: ',num2str(year),'; depth: ',num2str(depth),' m'],'fontsize',16);
print(h,'lambert_temperaturen_fesom_monat','-dpng');
end
By using the mask, you ensure that only valid data points are considered for plotting, eliminating the need to replace NaN values with zeros and preventing the coloring of empty regions over the coastlines.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by