Skip to content
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

🐛 fix: incorrect rgb colors #281

Merged
merged 1 commit into from
Feb 22, 2024
Merged

🐛 fix: incorrect rgb colors #281

merged 1 commit into from
Feb 22, 2024

Conversation

srj31
Copy link
Contributor

@srj31 srj31 commented Feb 22, 2024

Plotly treats decimal numbers for rgb value weirdly, where if rgb values are (0.9, 0, 0) it uses 0.9 as a percentage to display bright red

Fixes #279

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Copy link
Member

@RichDom2185 RichDom2185 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change does need seem correspondent with the PR description; how does the fix for operation ordering solve the issue?

@martin-henz
Copy link
Member

Well, the description is a bit strange. It's clear that the original implemention intended to scale the color values by a factor of 255. The original implementation assumed that ?? has higher precedence than *. However, ?? has lower precedence than *. So

pt.color[1] ?? 0 * 255;

is parsed like

pt.color[1] ?? (0 * 255);

which was obviously wrong because the color value isn't scaled at all. The PR fixes this bug.

@RichDom2185
Copy link
Member

Well, the description is a bit strange.

Yeah, it is. But I agree, the operation ordering is definitely incorrect. I guess we can merge this first and reopen the issue if it still persists.

@RichDom2185 RichDom2185 merged commit c1c9183 into master Feb 22, 2024
3 checks passed
@RichDom2185 RichDom2185 deleted the fix_279 branch February 22, 2024 11:01
@srj31
Copy link
Contributor Author

srj31 commented Feb 22, 2024

I wanted to explain why the error was not caught before when tested with different inputs. For e.g. pt.color[0] ?? 0 * 255 would return 0.9 which plotly would convert it to the 0...255 range value and it looked as if it worked correctly.

@martin-henz
Copy link
Member

Ah, makes sense. Thanks!

@martin-henz
Copy link
Member

I wanted to explain why the error was not caught before when tested with different inputs. For e.g. pt.color[0] ?? 0 * 255 would return 0.9 which plotly would convert it to the 0...255 range value and it looked as if it worked correctly.

It's fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plotly: Colors not showing
3 participants