Skip to content

Passing color as tuple not working as expected #4716

Open

Description

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

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

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