How to change the contour discretization in ezcontourf
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(2 个)
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.
0 个评论
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?
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Contour Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!