Azzera filtri
Azzera filtri

How to change the contour discretization in ezcontourf

2 visualizzazioni (ultimi 30 giorni)
Morten
Morten il 1 Ott 2014
Risposto: Anthony il 12 Ott 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.

Risposte (2)

Bruno Pop-Stefanov
Bruno Pop-Stefanov il 1 Ott 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 il 12 Ott 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?

Categorie

Scopri di più su Graphics Object Programming in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by