temperature range of file not seen in plot or matching colorbar

조회 수: 1 (최근 30일)
Aomawa
Aomawa 2024년 3월 20일
댓글: Aomawa 2024년 3월 20일
I know the maximum temperature reached in a netcdf file I'm working with is 314 K. However, when I plot it using countourf, neither that temperature nor anything close to it is visible in the plot. And the colorbar color assigned to this max temp does not match what I'm seeing in the plot. Here is the code I'm using:
ncfile1='./ANN_climo.nc';
var1='TS';
tmp1=squeeze(ncread(ncfile1,var1));
lat=ncread(ncfile1,'lat');
lev=ncread(ncfile1,'lev');
lon=ncread(ncfile1,'lon');
%checking max/min temps
max(max(tmp1))
min(min(tmp1))
%plotting
tmp2 = transpose(tmp1);
contourf(lon,lat,tmp2, 'LineStyle','none');
hold on
%adding dotted line for freezing point
contourf(lon,lat,tmp2, [273.0,273.0], 'linestyle', 'none');
contourf(lon,lat,tmp2,[273.0,273.0], 'linestyle', '--', 'linecolor', 'k')
%specifying the colormap
colormap('turbo')
%check default colorbar limits
caxis
set(gca,'fontsize',14);
ylabel('Latitude (\circ)')
xlabel('Longitude (\circ)')
h = colorbar;
xlabel(h,'(K)');
hold off
What am I missing?

답변 (1개)

Cris LaPierre
Cris LaPierre 2024년 3월 20일
Without the data, we can only speculate.
I suspect you are not seeing it because you have programmatically set the contour line to 273.
contourf(lon,lat,tmp2, [273.0,273.0], 'linestyle', 'none');
From the doc page description of the levels input: "To draw contour lines at a single height k, specify levels as a two-element row vector [k k]"
What if you just try
contourf(lon,lat,tmp2,'linestyle', 'none');
  댓글 수: 2
Aomawa
Aomawa 2024년 3월 20일
Thank you. I tried to upload the netcdf file but it is too large.
My first contourf line is contourf(lon,lat,tmp2, 'LineStyle','none')
Are you saying I am overriding that when I plot the freezing point line on top of it?
Aomawa
Aomawa 2024년 3월 20일
I just tried it. You were right. Thank you so much. I appreciate it greatly!!!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by