Skip to content

Passing color as tuple not working as expected #4716

Description

@juergensturm

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.

We are aware that passing colors as a list of [r,g,b] is not supported, so feel free to close this bug as invalid.
https://plotly.github.io/plotly.py-docs/generated/plotly.graph_objects.scatter3d.html#plotly.graph_objects.scatter3d.Marker.color

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

renders as expected (red/green/blue).

Activity

  1. emilykl commented on Sep 2, 2026

    @emilykl
    Contributor

    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:

    Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething broken

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions