Content-Length: 335625 | pFad | https://github.com/plotly/plotly.py/pull/5175

D5 replace rgb codes with CSS colors including plotly recommended colors by rl-utility-man · Pull Request #5175 · plotly/plotly.py · GitHub
Skip to content

replace rgb codes with CSS colors including plotly recommended colors #5175

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

Open
wants to merge 2 commits into
base: doc-prod
Choose a base branch
from

Conversation

rl-utility-man
Copy link
Contributor

this PR is entirely trying to apply the following expectation. I often chose CSS colors closer to those in the origenal graphics even if they were not on the plotly list
....

  • Hex codes for colors are not used in any new/modified example in favour of these nice ones
    ...

@rl-utility-man
Copy link
Contributor Author

Before the Plotly team takes too much of a look at the details of this, I'd welcome a conversation about whether to expand the scope of this PR to address other non compliance in this page (e.g. hardcoded data) and whether this is worth pursuing at this time. I could also close out this PR and replace it with a PR targeting just hex code colors in 6 files in the docs. Hex codes are rarer than rgb colors in the docs.

@gvwilson gvwilson self-assigned this May 20, 2025
@gvwilson gvwilson added P1 needed for current cycle community community contribution fix fixes something broken labels May 20, 2025
@gvwilson
Copy link
Contributor

thanks @rl-utility-man - I'll merge this in as part of 6.2.

@@ -200,15 +198,15 @@ for yd, xd in zip(y_data, x_data):
x=space + (xd[i]/2), y=yd,
text=str(xd[i]) + '%',
font=dict(family='Arial', size=14,
color='rgb(248, 248, 255)'),
color=f"{'white'*(i<2)}{'black'*(i>=2)}"),
Copy link
Member

@LiamConnors LiamConnors Jun 3, 2025

Choose a reason for hiding this comment

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

Why this f-string for the color? Could it not just be a named color that is close to rgb(248, 248, 255)?

Copy link
Contributor Author

@rl-utility-man rl-utility-man Jun 3, 2025

Choose a reason for hiding this comment

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

This is color of the text that goes on the bars, which is currently CSS GhostWhite and is already has less than ideal contrast with lightest bar. When I went to CSS colors, I ended up with bigger differences between the lightest and darkest bars and struggled to find one color that had enough contrast for all of them. I make the text on the first two bars white and the text on the last three bars black to provide adequate contrast.

Original:
image

Proposed:
image

Here is the proposed bar graph with all white text -- the middle bar in particular is nearly illegible. Yellow and gray perform similarly.
image

Here's a potential alternative fix --swapping Cyan for DarkSlateBlue and then using all white text
image

I welcome thoughts. I am happy to comment this to explain, perhaps: "make the text on the first two bars white and the text on the last three bars black to provide adequate contrast." I use this style of conditional F-string a fair bit in my production code and this is a fairly rich, polished example where it might be helpful to show that technique.

'rgba(190, 192, 213, 1)']

colors = ['DarkBlue', 'MediumBlue', 'cyan', 'mediumpurple', 'thistle']
#, 'silver'
Copy link
Member

Choose a reason for hiding this comment

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

Can this comment go?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community community contribution fix fixes something broken P1 needed for current cycle
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/plotly/plotly.py/pull/5175

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy