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

ENH: extra colors generated by get_standard_colors #37604

Closed
ivanovmg opened this issue Nov 3, 2020 · 0 comments · Fixed by #37664
Closed

ENH: extra colors generated by get_standard_colors #37604

ivanovmg opened this issue Nov 3, 2020 · 0 comments · Fixed by #37664
Assignees
Labels
Enhancement Needs Triage Issue that has not been reviewed by a pandas team member
Milestone

Comments

@ivanovmg
Copy link
Member

ivanovmg commented Nov 3, 2020

Is your feature request related to a problem?

Not necessarily an issue, but one can get some code improvement and consistency in pandas.plotting._matplotlib.style.get_standard_colors, when it is related to cycling colors.
During refactoring of the module (#37203) it turned out that cycling the colors works in a strange (although tolerable way).

>>> from pandas.plotting._matplotlib.style import get_standard_colors
>>> get_standard_colors(num_colors=2, color='rgb')
'rgb'
>>> get_standard_colors(num_colors=3, color='rgb')
'rgb'
>>> get_standard_colors(num_colors=4, color='rgb')
'rgbr'
>>>

From the snippets above one can see that in the second and third examples work reasonable.
Meanwhile, the first one returns three colors, rather than two.
Extra color(s) will be ignored anyway, but in regards to the discussion in the referenced PR, the way of cycling colors can be improved #37203 (comment)

Describe the solution you'd like

I suggest using matplotlib's cycler (or other generator) to cycle through the colors obtained and get the exact number of colors required, without any extra.
This will simplify the code involving colors cycling in get_standard_colors.

Expected Output

>>> from pandas.plotting._matplotlib.style import get_standard_colors
>>> get_standard_colors(num_colors=2, color='rgb')
'rg'

API breaking implications

Will break some tests related to get_standard_colors only as they expect extra colors to be returned on some occasions.

Describe alternatives you've considered

See #37203 without involving modifications to color cycling.

@ivanovmg ivanovmg added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Nov 3, 2020
@ivanovmg ivanovmg self-assigned this Nov 3, 2020
@jreback jreback added this to the 1.2 milestone Nov 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants