Add optional distinctipy
@@ -2,6 +2,13 @@ import matplotlib.pyplot as plt
import random
+try:
+ import distinctipy
+ HAVE_DISTINCPY = True
+except ImportError:
+ HAVE_DISTINCPY = False
+
+
def get_unit_colors(sorting, map_name='gist_ncar', format='RGBA', shuffle=False):
"""
Return a dict colors per units.
@@ -12,6 +19,9 @@ def get_unit_colors(sorting, map_name='gist_ncar', format='RGBA', shuffle=False)
unit_ids = sorting.unit_ids
+ if HAVE_DISTINCPY:
+ colors = distinctipy.get_colors(unit_ids.size)
+ else:
# some map have black or white at border so +10
margin = max(4, len(unit_ids) // 20) // 2
cmap = plt.get_cmap(map_name, len(unit_ids) + 2 * margin)
