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)
Ältere Kommentare anzeigen
MathWorks Support Team
am 2 Sep. 2014
Bearbeitet: MathWorks Support Team
am 3 Mär. 2021
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
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.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Contour Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!