필터 지우기
필터 지우기

How to change the contour discretization in ezcontourf

조회 수: 2 (최근 30일)
Morten
Morten 2014년 10월 1일
답변: Anthony 2014년 10월 12일
So basically I want the plot from this
syms x1 x2
f(x1,x2) = (x1^2 + x2 - 11)^2 + (x1 + x2^2 - 7)^2
figure
ezcontourf(f)
To look like this (but using ezcontourf), and not having to explicity convert it to a matrix.
v = [0:2:10 10:10:160 160:5:175 175:2:181 200:50:500];
X1=-5:0.01:5;
X2=-5:0.01:5;
[x1,x2] = meshgrid(X1,X2);
f2 =(x1.^2 + x2 - 11).^2 + (x1 + x2.^2 - 7).^2;
figure
[c,h]=contourf(x1,x2,f2,v);
set(h,'LineStyle','none')
I found this http://www.mathworks.se/help/matlab/ref/contourgroupproperties.html, and thought maybe the 'LevelList' property could be the solution, but somehow I can't seem to get the handle of the plot returned by ezcontourf.
In summary, I want to be able to change the contour color intervals in ezcontour so that I don't loose the dynamics which can be seen by comparing the two above plots--in the ezcontour plot, the whole center seems flat, where in the second plot, defined by the intervals v, it's possible to see the center is not completely flat.

답변 (2개)

Bruno Pop-Stefanov
Bruno Pop-Stefanov 2014년 10월 1일
The contour graphics object will be a child of the axes. You can get the children of the axes with:
>> children = get(gca,'Children');
If there is nothing in the axes but the contour plot, then there will be only one child and you can directly do:
>> set(children,'LevelList',[0:2:10 10:10:160 160:5:175 175:2:181 200:50:500])
Adding
>> set(children,'LineStyle','none')
will give you the exact same plot.

Anthony
Anthony 2014년 10월 12일
I have a question to extend off of that. Say you had several ezcontour functions and you wanted to display them on the same figure with different colors for each one, how would you go about that?

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by