You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Passing color as tuple not working as expected #4716
We want to plot colored point clouds. We have the colors as a numpy array of type uint8, but the bug also occurs when we simply pass a list of [r,g,b] values.
However, the odd thing (and that is unexpected) is that it doesn't yield an error when we pass the colors in this way. However, when one of the values (r/g/b) equals 1, we get the wrong color. This does not happen for 0 or 2 (or any other number).
Minimal example:
import plotly.graph_objs as go
go.Figure().add_trace(go.Scatter3d(x=[1,2,3], y=[1,1,1], z=[1,1,1], mode='markers', marker=dict(color=[[255, 0, 0], [1, 255, 0], [0, 0, 255]], size=10)))
produces red/yellow/blue dots (instead of red/green/blue).
In other cases, we observe that we get white (for example for [1,255,1]).
FWIW, the problem does not occur if we scale the values to 0..1:
import plotly.graph_objs as go
go.Figure().add_trace(go.Scatter3d(x=[1,2,3], y=[1,1,1], z=[1,1,1], mode='markers', marker=dict(color=[[1, 0, 0], [1/255., 1, 0], [0, 0, 1]], size=10)))
Hi @juergensturm, apologies for the very delayed follow-up!
This bug is a consequence of some legacy behavior in plotly.js, where color channel values between 0-1 (inclusive) were interpreted on a 0-1 scale, which caused the value 1 to be displayed equivalently to 255.
Activity
emilykl commentedon Sep 2, 2026
Hi @juergensturm, apologies for the very delayed follow-up!
This bug is a consequence of some legacy behavior in plotly.js, where color channel values between 0-1 (inclusive) were interpreted on a 0-1 scale, which caused the value 1 to be displayed equivalently to 255.
That behavior has been removed by plotly/plotly.js#7536 and plotly/plotly.js#7962, and first released in plotly.js v4.0.0 / plotly.py v7.0.0. The dots in your example now render red / green / blue as expected: