Allow tuples of 4 floats as color rcparams.#9038
Conversation
|
Huh... |
|
@anntzer Would it be worth to add this kind of snippet # One would need to also import validate_color beforehand
{'validator': validate_color,
'success': (('None', 'none'),
('none', 'none'),
('AABBCC', '#AABBCC'), # RGB hex code
('AABBCC00', '#AABBCC00'), # RGBA hex code
('tab:blue', 'tab:blue'), # named color
('C0', 'C0'), # color from cycle
('(0, 1, 0)', [0.0, 1.0, 0.0]), # RGB tuple
((0, 1, 0), (0, 1, 0)), # non-string version
('(0, 1, 0, 1)', [0.0, 1.0, 0.0, 1.0]), # RGBA tuple
((0, 1, 0, 1), (0, 1, 0, 1)), # non-string version
('(0, 1, "0.5")', [0.0, 1.0, 0.5]), # unusual but valid
),
'fail': (('tab:veryblue', ValueError), # invalid name
('C123', ValueError), # invalid RGB(A) code and cycle index
('(0, 1)', ValueError), # tuple with length < 3
('(0, 1, 0, 1, 0)', ValueError), # tuple with length > 4
('(0, 1, none)', ValueError), # cannot cast none to float
),to FWIW, currently (on Matplotlib 2.0.2) |
|
I honestly care very little about the rcparam validator because, as I have already argued in many places, I think its entire design should be redone from scratch (to just use python expressions as syntax, either through eval or through a hand-written safe AST evaluator if we consider it worth it). |
|
Something like should work. Perhaps this should go to the devdocs, btw. |
|
Thank you @anntzer, I was severely missing the first line ^^. Almost there now but it looks like I am still missing something for pushing... A simple Of course the suggested solution just made a branch on my own fork, while replacing |
|
What are these consequences? (dunno) |
|
I cherry-picked @afvincent 's second commit and pushed it to this branch. |
|
BTW @anntzer, the "consequences" were that I created a new branch on the upstream Matplotlib repository :/. Huh, seems like I let a white blank line on my initial branch on my own fork, which causes PEP8 failures. Too bad, I had it remove on the branch I created on the upstream repository ^^. |
|
Sorry about the wrong instructions then :/ |
|
Don't be: thanks to them I already went further than I had before ;). |
Fixes #9030 (comment).
(Although I still think (as argued in many other places) that the proper solution is to use Python files, or at least a full Python expression evaluator, as rcfile.)
PR Summary
PR Checklist