Random Color Palette Generation with Seaborn

  • Share this:

Code introduction


This function uses the palplot method from the Seaborn library to generate a random color palette and returns the list of this palette.


Technology Stack : Seaborn, Numpy, Pandas

Code Type : Function

Code Difficulty : Intermediate


                
                    
import seaborn as sns
import numpy as np
import pandas as pd

def random_color_palette():
    """
    Generate a random color palette.
    """
    def generate_color():
        return np.random.rand(3,)

    palette = [generate_color() for _ in range(5)]
    sns.palplot(palette)

    return palette