How to set contour levels

조회 수: 27 (최근 30일)
University Glasgow
University Glasgow 2023년 2월 17일
편집: University Glasgow 2023년 2월 17일
Hi, I'm trying to plot a contour. I tried this:
contourf(u, xi, Da1(:, :), 50);
and I got the attached figure Contour1 with contour levels of 50. However, I didn't get the desired result. I expected the zero region, which is for values of \xi_c above zero and some \xi_c values below zero. But is not matching with the contour levels. There are regions that are non- zero but still show blue colour. I want the blue colour to correspond to only zero levels of the contour and any other levels to assume different colors.
In an attempt to achieve this, I tried this:
contourf(u, xi, Da1(:, :), 10.^( min(Da1(:, end)) : 0.02: max(Da1(:, end))));
I got the second figure: Contour2, which is not what I'm expecting. Why is it showing a white region that is not on the contour legend? Please how can I fix this.

답변 (1개)

Steven Lord
Steven Lord 2023년 2월 17일
and I got the attached figure Contour1 with contour levels of 50
No, that syntax creates 50 contour levels. To specify a single contour level at an integer-valued level (to avoid ambiguity with the number of contour levels syntax) you need to specify a vector with two elements each of which is the contour level. Compare:
[x, y, z] = peaks;
contour(x, y, z, 2)
title('2 contour levels')
figure
contour(x, y, z, [2 2])
title('contour level at z = 2')
  댓글 수: 1
University Glasgow
University Glasgow 2023년 2월 17일
편집: University Glasgow 2023년 2월 17일
Thank you Steven, Do mean something like this:
contourf(u, xi, Da1(:, :), [-2 2]);
I got the attached figure. I'm suspecting that is not correct because the region between the two yellow colors in the attached figure is nonzero. Is is possible to replace that region with different color apart from blue?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by