如何在Matlab中自定义轮廓线? [英] How to customize contour lines in Matlab?

查看:486
本文介绍了如何在Matlab中自定义轮廓线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在准备等高线图,应该在其中突出显示特定级别的等高线.例如,我的轮廓线值在-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中自定义轮廓线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆