Hi,
I’m using plotly with Python, and am having some trouble with the colorscale
property - I don’t think it’s mapping the values to the colours correctly:
The input is a list of 5000 values from a Normal distribution with mean 0 and variance 1.
The colorscale should be blue for values < -0.25, white for values between -0.25 and 0.25, and red for values greater than 0.25. Note, this is for the values.
Of course, with colorscale we have to map values onto the interval [0,1], so I’ve done this. This input
print(
value_to_percentile(fake_values, -0.25),
value_to_percentile(fake_values, 0),
value_to_percentile(fake_values, 0.25)
)
produces this output: 0.394 0.4912 0.5884
, which looks pretty close to what we’d expect from a standard normal distribution.
My colorscale is as follows:
colorscale=[
[0, 'rgb(0,0,255)'],
[value_to_percentile(fake_values, -0.25), 'rgb(0,0,255)'],
[value_to_percentile(fake_values, -0.25), 'rgb(255,255,255)'],
[value_to_percentile(fake_values, 0), 'rgb(255,255,255)'],
[value_to_percentile(fake_values, 0.25), 'rgb(255,255,255)'],
[value_to_percentile(fake_values, 0.25), 'rgb(255,0,0)'],
[1, 'rgb(255,0,0)']
]
which I believe accurately represents what I outlined above for the colours I want.
However, my colorscale is coming out like this:
Where the thresholds are more like +/- 0.7 than +/- 0.25. Any idea what’s going wrong?
Thanks