Black Lives Matter. Please consider donating to Black Girls Code today.
Dash Enterprise delivers an incredible 21x cost savings 💸Download the e-book!

A question about (Scatter with a Color Dimension)

maybe my question isn’t good .but I thought and couldn’t figure out. here is code (this code is from Scatter tutorial in plotly):

import plotly.graph_objs as go
import plotly.plotly as py

import numpy as np

trace1 = go.Scatter(
y = np.random.randn(500),
color = np.random.randn(500), #set color equal to a variable
data = [trace1]

py.iplot(data, filename=‘scatter-plot-with-colorscale’)

in here any relationship between color and variables?

we set “showscale=True” and my question is why markers with lowcolor in scale are above axis?

for example yellow markers have 2variables but we see some of them have -1.5 var in scatter,and they are below axis

Hey @arminoldboy,

The trace given as example, illustrates how to color the dots according to the numerical values in color. It works as follows:
The values in color, of min value a, and max value b, are mapped to [0,1] via v in [a,b]–>(v -a)/(b-a) in [0,1].
The colorscale in Plotly is a list of lists as in this example:

pl_colorscale=[[0.0, 'rgb(46, 107, 142)'],
[0.1, 'rgb(41, 121, 142)'],
[0.2, 'rgb(36, 134, 141)'],
[0.3, 'rgb(31, 147, 139)'],
[0.4, 'rgb(30, 160, 135)'],
[0.5, 'rgb(40, 174, 127)'],
[0.6, 'rgb(59, 186, 117)'],
[0.7, 'rgb(85, 198, 102)'],
[0.8, 'rgb(116, 208, 84)'],
[0.9, 'rgb(151, 216, 62)'],
[1.0, 'rgb(189, 222, 38)']]

Now to each point of coordinates (X,Y) corresponds a value in color, that is mapped to a value in [0,1] by the above defined function, and to this normalized value corresponds, via linear interpolation, a color in the colorscale. Hence the color does not point out the position of the point with respect to x and yaxis.