每 100m 等高线图标签

Contour plot labels every 100m

我有我正在使用 contour

绘制的地中海测深数据
%open netcdf file 
latu=ncread('/media/Elise/ELISEV32/LECOB/Netcdf1/grid.nc','latitude_u'); 
lonu=ncread('/media/Elise/ELISEV32/LECOB/Netcdf1/grid.nc','longitude_u');

depw=ncread('/media/Elise/ELISEV32/LECOB/Netcdf1/grid.nc','depth_w');
    [m,n]=size(depw(:,:,1));
    %Delete values with a depth deeper than 4000 to increase the accuracy of the map since the default value of no data is -999999
    for i=1:m
        for j =1:n
            if depw(i,j,1) <-4000
                depw(i,j,1);
                depw(i,j,1)= NaN;
            end
        end
    end

figure

[M,c]=contour(lonu(1:681,1:711),latu(1:681,1:711),depw(1:681,1:711,1),50,'ShowText','on');

这为我提供了以下法国南部狮子湾的地图。

如您所见,这是不可读的。有没有办法只每十行绘制一次文本?

可以调整contour对象的TextList属性:

num_lines = 30;
line_skip = 5;

[X,Y,Z] = peaks(25);

figure(1); clf;
[M,c] = contour(X,Y,Z,num_lines,'ShowText','on');

c.TextList = c.TextList(1:line_skip:end);