✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚾️ It's finally Baseball season! Root for the home team... & Register for our Sports Analytics Webinar!

How to generate 3D surface plot using a color scale that comprises of colors like Red,Yellow & Green

How to generate 3D surface plot using a color scale that comprises of colors like Red,Yellow & Green

Please have a look at the attached sampleRed_Yellow_Green

Alternatively, if I can get some direction on how the Colors are derived for the different predefined color-scales i.e. the rgb values for different ranges of Z coordinate, I could try to tweak those to generate similar color pattern for my plots.

See https://plot.ly/javascript/colorscales/#custom-colorscale for an example of a custom colorscale.

Thanks for your reply…actually the custom color scale doesn’t change colors as specified by the rgb values.
There are several 3D plots throughout my application with varying range for Z-coordinate.

For one particular plot it varies from ‘0.89’ to ‘1.0’ , where I am trying to test custom color scale , with the below values :-
colorscale : [
[‘0.8’, ‘rgb(255,0,0)’]
[‘1.0’, ‘rgb(0,255,0)’]
]

Still the plots don’t show up the colors as specified i.e. red & green.

Basically, Colorscales for me doesn’t seem to work at all.

Please guide on this.

Try

colorscale : [
[‘0’, ‘rgb(255,0,0)’]
[‘1.0’, ‘rgb(0,255,0)’]
]

instead. Colorscales must be defined from 0 to 1.

More info here -> https://plot.ly/javascript/reference/#surface-colorscale

I have already tried the custom ‘colorscale’ property with the given color scales :-

colorscale : [
[‘0’, ‘rgb(255,0,0)’]
[‘1.0’, ‘rgb(0,255,0)’]
]

The colors just refuse to change :frowning:

Also, I have based the color scale on x-axis with the following attribute:
surfacecolor: xArray[0]
Here xArray contains value for x-axis which is a 1D array of values spanning from 500.00 to 7000.00 in steps of 250.

Still nothing changes!! Please see pic below,

Its working now!!..I am able to construct images with these 3 colors, though the surfacecolor attribute does not work my purpose is solved now…

I have another query related to creation of grids for all the 3 axes which I will be posting in a separate thread…

Thanks a lot for your kind help!!