How to change the contour discretization in ezcontourf

1 Ansicht (letzte 30 Tage)
Morten
Morten am 1 Okt. 2014
Beantwortet: Anthony am 12 Okt. 2014
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.

Antworten (2)

Bruno Pop-Stefanov
Bruno Pop-Stefanov am 1 Okt. 2014
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 am 12 Okt. 2014
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?

Kategorien

Mehr zu Contour Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by