temperature range of file not seen in plot or matching colorbar

1 次查看(过去 30 天)
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