【问题标题】:Matlab "Patch" equivalent in scilabscilab 中的 Matlab“补丁”等价物
【发布时间】:2017-03-07 12:45:02
【问题描述】:

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

在 Matlab 中的 patch 命令中,我可以在顶点指定颜色,与实数给出的值成比例(例如,值为 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] )

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

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

谢谢

【问题讨论】:

    标签: matlab plot scilab


    【解决方案1】:

    给定的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()
    

    会产生更连续的颜色图,反映稍微不同的颜色

    【讨论】:

      猜你喜欢
      • 2021-11-02
      • 2016-09-18
      • 2018-05-29
      • 2020-02-13
      • 2015-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多