0
votes

I need to plot a quad face in Scilab with the command Plot3d, but I am unable to find a way to assign a color at the vertex, proportional to a real value.

In the patch command in Matlab, I can assign a color at the vertex, proportional to a value given by a real number (for example, a vertex with a value of 3.6 will have a different color than a vertex with a value of 3.2).

In scilab, it seems that the plot3D is able to manage only integer values.

I tried the following code:

    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] )

but the colors are the same, even if the values specified in the matrix colors are slightly different.

Anyone knows how to fix this problem?

Thanks

1

1 Answers

0
votes

The colors argument given are used as indices (thus integer) to lookup the color in the colormap. And that is why they are the same.

In your example you could scale your color list and set a large colormap that has more values. For instance

//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()

Would result in a more continuous colormap which would reflect slightly different colors

Continuous colormap