필터 지우기
필터 지우기

Contourf: fill inside instead of outside

조회 수: 21 (최근 30일)
Marco Sammito
Marco Sammito 2019년 4월 7일
댓글: DGM 대략 22시간 전
Hi, how can I fill the area within the circle? At the moment Matlab fills the area outside. I would like the outside to be white and the inside to be filled. Thanks.
relamdt=-4:0.1:4;
imlamdt=-4:0.1:4;
[x,y]=meshgrid(relamdt,imlamdt);
axis square;
lamdt=x+i*y;
sig = (1 + lamdt);
v = [1,1];
contourf(x,y,abs(sig),v)
Screenshot_2019-04-08_09-54-58.png

채택된 답변

Walter Roberson
Walter Roberson 2019년 4월 8일
편집: Walter Roberson 2019년 4월 8일
contourf(x, y, -abs(sig), -v)
Alternately, possibly
[~,h] = contourf(x, y, abs(sig), v);
drawnow(); %seems to be needed to get NodeChildren created
bg = h.NodeChildren(2).ColorData;
h.NodeChildren(2).ColorData = uint8([255; 255; 255; 255]);
ax = ancestor(h,'axes');
ax.Color = bg;

추가 답변 (2개)

David Wilson
David Wilson 2019년 4월 8일
A quick hack (following the essence of your code) is
cmap = colormap; cmap(end,:) = [1,1,1]; colormap(cmap);
contourf(x,y,abs(sig),[0,1]);
axis square
  댓글 수: 1
Marco Sammito
Marco Sammito 2019년 4월 8일
It does not seem to affect anything. The area within the circle is still white: the outside is still green. I would like to invert these two. Inside=green, outside=white.

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


Roberto Tumolo
Roberto Tumolo 대략 22시간 전
What if one wants to extract the values shown inside and outside (suppose you don't know them because they come from a contour?
  댓글 수: 1
DGM
DGM 대략 22시간 전
The way the question is posed makes it unclear what information we might have. From a contour()/contourf() object, we can know a set of discrete z-values associated with the given level curves, but unless we have access to the original zdata, we don't know the actual values between the level curves. If we don't have access to the object itself (e.g. if all we have is a saved figure as a raster image (a screenshot)), then things get more restricted.

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by