This adds ColorScheme, which includes all supported color schemes as ColorScheme.name, and has a constructor which will change the color scheme strings as needed. This is intended to help discovery, (eg. IDE will show available colors, or you can look in __init__.py instead of going to d3 documentation, which won't specify that d3.scheme____ is required), and ensure that the user knows why their color choice failed.
>>> ColorScheme(5).Blues
d3.schemeBlues[5]
It also checks that d3 supports the given value of k (length) for the given color scheme, and raises an error if that is not the case - which is helpful if you get a blank page and don't know why.
This adds ColorScheme, which includes all supported color schemes as ColorScheme.name, and has a constructor which will change the color scheme strings as needed. This is intended to help discovery, (eg. IDE will show available colors, or you can look in
__init__.py
instead of going to d3 documentation, which won't specify that d3.scheme____ is required), and ensure that the user knows why their color choice failed.It also checks that d3 supports the given value of k (length) for the given color scheme, and raises an error if that is not the case - which is helpful if you get a blank page and don't know why.
Additionally, you don't need to call len(), so it's as easy as
The following blocks show equivalent usages.