You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import types
from operator import attrgetter
import palettable
def recursePalettablePalettes(module, palettes, root=None, depth=0):
"""
Walk the modules in palettable to find all of the available palettes.
:param module: the current module.
:param palettes: a set to add palette names to.
:param root: a string of the parent modules. None for palettable itself.
:param depth: the depth of the walk. Used to avoid needless recursion.
"""
for key in dir(module):
if not key.startswith('_'):
attr = getattr(module, key)
if isinstance(attr, types.ModuleType) and depth < 3:
recursePalettablePalettes(
attr, palettes, root + '.' + key if root else key, depth + 1)
elif root and isinstance(getattr(attr, 'hex_colors', None), list):
palettes.add(root + '.' + key)
palettes = set()
_recursePalettablePalettes(palettable, palettes)
print(sorted(palettes))
And, of course, you can use a name like cartocolors.qualitative.Pastel_10 by just doing something like palette = attrgetter('cartocolors.qualitative.Pastel_10')(palettable).hex_colors.
It be nice there were an equivalent built in function.
How to get all colormap instannce ? I want to make one picture incluse all colormap
The text was updated successfully, but these errors were encountered: