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

12 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 3 de Mzo. de 2021
Editada: MathWorks Support Team el 3 de Mzo. de 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.

Más respuestas (0)

Categorías

Más información sobre Contour Plots en Help Center y File Exchange.

Productos


Versión

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by