Skip to content

Missing clipping in n_colors #4105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tschuelia opened this issue Mar 15, 2023 · 0 comments · Fixed by #4110
Closed

Missing clipping in n_colors #4105

tschuelia opened this issue Mar 15, 2023 · 0 comments · Fixed by #4110
Labels
bug something broken

Comments

@tschuelia
Copy link

Hello!

I'm using the n_colors function to generate a list of colors in RGB space and I got the following error message trying to use the generated colors in a plot:
Received value: 'rgb(-2.842170943040401e-14, 255.00000000000003, 0.0)'

Looking at the code for n_colors, I noticed that the computed float values are used directly, however there should be a clipping applied to make sure the values are between 0 and 255.

You should be able to reproduce this issue like this:

from plotly.colors import n_colors
n_colors(lowcolor="rgb(255,0,0)", highcolor="rgb(0,255,0)", n_colors=14, colortype="rgb")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants