How can I make the contour plot of an "sfit" object resemble the plot generated by the "contour" command in MATLAB R2013b?

조회 수: 12 (최근 30일)
I am making a surface fit using the "fit" function and using it to generate a contour plot with the following code:
load franke
sf = fit([x y], z, 'poly23');
plot(sf, 'Style', 'Contour');
This generates the following plot:
However, the plot that is generated looks different from what I would get by using the "contour" function.  How can I make it look the same?

채택된 답변

MathWorks Support Team
MathWorks Support Team 2021년 3월 3일
편집: MathWorks Support Team 2021년 3월 3일
If the code is modified so that the plot function returns a handle to the generated contourgroup, the 'Fill' and 'LineColor' properties of the contourgroup can be set to 'off' and 'auto', respectively.  Additionally, the grid off command can be used to remove the grid lines:
load franke
sf = fit([x y], z, 'poly23');
ph = plot(sf, 'Style', 'Contour');
set(ph, 'Fill', 'off', 'LineColor', 'auto');
grid off;
This will produce the following plot:
This resembles the output that is achieved if the "contour" command
is used.  Note also that the contour matrix used to generate the plot can be accessed, as it is a property of the contourgroup.  It can then be used to generate contour labels if desired with the "clabel" function:
C = get(ph, 'ContourMatrix');
clabel(C, ph);
This produces the following plot:
For additional properties of the contour, please refer to the documentation page.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by