Generate N random colors ############################ For the creation of **N unique colors** can be done with :func:`colourmap.colourmap.generate`. .. code:: python # Import library import colourmap as colourmap # Number of colors to print N = 5 # Generate colors c = colourmap.generate(N) # Generate colors using different cmap c_rgb = colourmap.generate(N, cmap='Set2') print(c_rgb) # array([[0.4, 0.76078431, 0.64705882], # [0.55294118, 0.62745098, 0.79607843], # [0.65098039, 0.84705882, 0.32941176], # [0.89803922, 0.76862745, 0.58039216], # [0.70196078, 0.70196078, 0.70196078]]) Create color based on input labels ###################################### For the creation of **N unique colors** for the **N input labels** can be performed with :func:`colourmap.colourmap.fromlist`. .. code:: python # Import library import colourmap as colourmap # Target labels y=[1, 1, 2, 2, 3] # String as input labels y=["1", "1", "2", "2", "3"] # Generate colors c_rgb, c_dict = colourmap.fromlist(y) print(c_rgb) # [[0.89411765 0.10196078 0.10980392] # [0.89411765 0.10196078 0.10980392] # [1. 0.49803922 0. ] # [1. 0.49803922 0. ] # [0.6 0.6 0.6 ]] print(c_dict) # {1: array([0.89411765, 0.10196078, 0.10980392]), # 2: array([1. , 0.49803922, 0. ]), # 3: array([0.6, 0.6, 0.6])} # Grab color for label 2 c_dict.get(2) Color generated by seaborn and matplotlib ############################################ Two methods are implemented to generate the colormaps, with the function: :func:`colourmap.colourmap.generate`. * seaborn * matplotlib .. code:: python # Import library import colourmap as colourmap # Seaborn c_rgb_1 = colourmap.generate(5, method='seaborn') # Matplotlib c_rgb_2 = colourmap.generate(5, method='matplotlib') Convert RGB to HEX #################### Converting RGB to HEX can be performed with the function :func:`colourmap.colourmap.rgb2hex`. .. code:: python # Import library import colourmap as colourmap # String as input labels y=["1", "1", "2", "2", "3"] # Generate colors c_rgb, c_dict = colourmap.fromlist(y) print(c_rgb) # [[0.89411765 0.10196078 0.10980392] # [0.89411765 0.10196078 0.10980392] # [1. 0.49803922 0. ] # [1. 0.49803922 0. ] # [0.6 0.6 0.6 ]] # Convert to HEX c_hex = colourmap.rgb2hex(c_rgb) # Convert to HEX but keep alpha transparancy c_hex = colourmap.rgb2hex(c_rgb, keep_alpha=True) print(c_hex) # array(['#e41a1c', '#e41a1c', '#ff7f00', '#ff7f00', '#999999'], dtype='