Skip to content

Colorscale should be betwen 0-255 or 0-1 but not a mixed behaviour #4942

Closed

Description

@emmanuelle

See the codepen:
https://codepen.io/emmanuelle-plotly/pen/ZEQKBwz

When defining a colorscale, a value of 'rgb(254.5,1.0,0)' is rendered as yellow, as if the red channel was considered to be in the [0-255] range and the green one in [0-1] (or maybe there is another explanation?). Changing the green value 1.0 to 1, 0.99 or 1.01 solves the issue (the color is red again).

I think this is a bug, or at least a counter-intuitive behaviour.

Mentioned on the forum https://community.plotly.com/t/float-number-in-colorscale/41428

Activity

  1. ryanh153 commented on Sep 28, 2021

    @ryanh153

    I got a similar issue with Scatter3d where the legend interprets the color on 0-1 scale but the marker interprets it on 0-255.

    Code:

    from plotly.subplots import make_subplots
    import plotly.graph_objects as go
    import numpy as np
    
    fig = make_subplots()
    fig.update_layout(height=600, width=1200)
    x , y, z = np.linspace(0, 100, 100), np.linspace(-10, 10, 100), np.linspace(5, 25, 100)
    fig.add_trace(go.Scatter3d(x=x, y=y, z=z, mode='markers', marker={'color': 'rgb(1.0, 0.0, 0.0)'}, name='Red'))
    fig.add_trace(go.Scatter3d(x=x+100, y=y, z=z, mode='markers', marker={'color': 'rgb(0.0, 0.0, 1.0)'}, name='Blue'))
    fig.show()
    

    Plot produced (in question on stack overflow):
    https://stackoverflow.com/questions/69364157/markers-too-dark-with-plotly-scatter3d

    Agreed that this is annoying would be nice to have fixed.

  2. self-assigned this
    on Jun 26, 2024
  3. removed their assignment
    on Aug 2, 2024
  4. emilykl commented on Aug 30, 2026

    @emilykl
    Contributor

    I think we can close this one now, since numeric color values are now always interpreted in the 0-255 range following the merge of #7536 / #7962.

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