在 MATLAB 中更改来自 SFIT 的曲面图的颜色

Change the color of a surface plot from SFIT in MATLAB

我有四个用于绘制的 SFIT 对象:

figure;
hold on;
plot(f1);
plot(f2);
plot(f3);
plot(f4);

这绘制了一个 3D 表面。 但是我想给每个表面一种独特的颜色,就像绘图函数中常见的那样。通常这是通过给参数 'r' 或指示颜色的东西来完成的,例如:

plot(f1,'r');

但是,如果我在这里这样做,我会收到以下错误:

Error using plot No value was given for 'r'. Name-value pair arguments require a name followed by a value.

Error in sfit/plot>iParseInputs (line 231) p.parse( parameterValuePairs{:} );

Error in sfit/plot (line 44) [XY, Z, in, out, style, level, hParent] = iParseInputs( obj, varargin{:} );

这表示必须要给一个String,请问是哪一个?我已经尝试过 'Color' 或 'LineColor' 之类的方法,但无法识别这些方法

问题的简化:我希望代表拟合对象的平面具有一种颜色。而且每个位面都不一样

由此link:

https://uk.mathworks.com/matlabcentral/answers/153208-how-can-i-make-the-contour-plot-of-an-sfit-object-resemble-the-plot-generated-by-the-contour-com

你可以试试

f1 = fit([x y], z, 'poly23');
ph = plot(f1, 'Style', 'Contour');
set(ph, 'Fill', 'off', 'LineColor', 'auto');

set

的文档

https://uk.mathworks.com/help/matlab/ref/set.html


编辑

以上建议仅显示 2D 图,有关 3D 情况,请参阅之前的 SO 答案:

您的相关代码是:

figure; 
h = plot(f1); 
set(h(1),'FaceColor','r');

所以你要找的 "magic word" 是 'FaceColor',与 set(上面提到的)结合使用。