フィルターのクリア

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 Center および File ExchangeColormaps についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by