Matlab "Patch" 等效于 scilab

Matlab "Patch" equivalent in scilab

我需要在 Scilab 中使用 Plot3d 命令绘制一个四边形面,但我无法找到一种方法来在顶点分配颜色,颜色与实际值成比例。

在 Matlab 的 patch 命令中,我可以在顶点分配颜色,与实数给定的值成比例(例如,值为 3.6 的顶点与值为 3.6 的顶点的颜色不同值为 3.2).

在 scilab 中,plot3D 似乎只能管理整数值。

我尝试了以下代码:

    xf = [0, 1; 1 ,2; 1, 2; 0, 1 ];
    yf = [1, 1;1, 2;1, 1;1, 1 ];
    zf = [0, 0 ; 0, 0; 5,5 ;5, 5 ];
colors = [1 1;2 2 ;3.5 3;4.5 4 ];
plot3d(xf,yf,list(zf,colors) ,[0,0,0,flag,3] )

但颜色是相同的,即使矩阵颜色中指定的值略有不同。

有人知道如何解决这个问题吗?

谢谢

给定的 colors 参数用作索引(因此是整数)以在颜色图中查找颜色。这就是它们相同的原因。

在您的示例中,您可以缩放 color 列表并设置具有更多值的大型颜色图。例如

//Assuming default flags
flags=[2,8,4]
xf = [0, 1; 1 ,2; 1, 2; 0, 1 ];
yf = [1, 1;1, 2;1, 1;1, 1 ];
zf = [0, 0 ; 0, 0; 5,5 ;5, 5 ];

colors = [1 1;2 2 ;3.5 3;4.5 4 ];
// Scale colors
max_value = max(colors)
nr_of_colors = 128
scaled_colors = colors / max_value * nr_of_colors

plot3d(xf,yf,list(zf,scaled_colors) ,[0,0,0,flag,3] )

// Set colormap
fig = gcf()
fig.color_map = hotcolormap(nr_of_colors)

// To show the current colormap
getcolor()

会产生更连续的颜色图,反映略有不同的颜色