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

16 Ansichten (letzte 30 Tage)
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?

Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 3 Mär. 2021
Bearbeitet: MathWorks Support Team am 3 Mär. 2021
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.

Weitere Antworten (0)

Kategorien

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

Produkte


Version

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by