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 Center および File ExchangeContour Plots についてさらに検索

製品


リリース

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by