<jupyter_start><jupyter_text>Inputs<jupyter_code># List of strings
cm = cb.ColorTranslator(['rgb(255, 0, 0)', 'rgb(0, 0, 255)'])
cm.show_colors()

# array of rgb
cm = cb.ColorTranslator([(255, 0, 0), (0, 0, 255)])
cm.show_colors()

# array of 0 - 1
cm = cb.ColorTranslator([(1, 0, 0), (0, 0, 1)])
cm.show_colors()

# Hex values
cm = cb.ColorTranslator(['#ff0000', '#0000ff'])
cm.show_colors()

# Name input
cm = cb.ColorTranslator(['red', 'blue'])
cm.show_colors()

# Colormap input
cmap = plt.cm.rainbow
cm = cb.ColorTranslator(cmap)<jupyter_output><empty_output><jupyter_text>Display<jupyter_code># Show color spectrum
cm.show_colors()
# As bins
cm.show_colors(10)<jupyter_output><empty_output><jupyter_text>Outputs<jupyter_code># To rgb arrays
nums = cm.to_numeric(n_bins=5)
sns.palplot(nums)
# Indexing subsets
sns.palplot(cm([0, .5, 1]))
sns.palplot(cm([0, 50, 100], vmin=0, vmax=100))
# Show a subset
cm([0, .5, 1], kind='html')
# To husl
husl = cm.to_numeric(n_bins=5, kind='husl')
husl
# To HTML hex codes
sns.palplot(cm.to_strings(n_bins=5, kind='hex'))
# To plotly strings
strings_a = cm.to_strings(n_bins=5)
strings_b = cm.to_strings(n_bins=5, kind='husl')
print('{}\n---\n{}'.format(strings_a, strings_b))
HTML(cl.to_html(strings_b))
# To a name for each color (if possible)
cm.to_strings(n_bins=5, kind='name')
# To diverging colormap (from cmap ends)
cb.ColorTranslator(cm.to_diverging()).show_colors()
cb.ColorTranslator(cm.to_diverging(center='dark')).show_colors()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18199867637326275, 'fraction_numerical': 0.03970880211780278, 'mean_word_length': 6.753846153846154, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '349545', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 691, 'n_tokens_neox': 640, 'n_words': 124, 'path': 'index.ipynb', 'repo_name': 'choldgraf/ColorBabel', 'size': '1511'}