问题描述
我正在准备等高线图,应该在其中突出显示特定级别的等高线.例如,我的轮廓线值在-1和1之间,并且我想突出显示与值0相对应的线.我尝试使用以下过程来做到这一点,
I am preparing a contour map where I am supposed to highlight the contour line for a specific level. For Example, my contour line values are lying between -1 and 1 and I want to highlight the line corresponding to the value 0. I tried to do this using the following procedure,
[M,c]=contourf(longitude,latitude,delta',-1:0.2:1);
s=size(c.LevelList,2);
for i=1:s
if (c.LevelList(i)==0)
c.LevelWidth=2;
end;
end;
但是,它对轮廓图没有任何作用.任何人都可以通过适当的程序帮助我吗?
However, it does nothing to the contour map. Can anyone please help me with the appropriate procedure?
推荐答案
我建议在所需的级别上简单地使用contour
在初始contourf
之后突出显示,例如:
I would suggest simply using contour
on your desired levels to highlight after the initial contourf
, like so:
% Input.
x = linspace(-2*pi, 2*pi, 101);
y = x + pi;
[X, Y] = meshgrid(x, y);
Z = 0.5 * (sin(X) + cos(Y));
% Levels to plot with contourf.
levelsf = -1:0.2:1;
% Levels to highlight.
levels = [0 0.3];
figure(1);
hold on;
% Contourf all levels.
contourf(X, Y, Z, levelsf);
% Highlight levels with simple contour.
contour(X, Y, Z, levels, 'r', 'LineWidth', 2);
hold off;
要突出显示levels = [0 0.3]
,您将获得:
For highlighting levels = [0 0.3]
, you'll get:
这篇关于如何在Matlab中自定义轮廓线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!