Choosing seaborn color palettes

Seaborn color palettes are similar to matplotlib colormaps. Color can help you discover patterns in data and is an important visualization component. Seaborn has a wide range of color palettes, which I will try to visualize in this recipe.

How to do it...

  1. The imports are as follows:
    import seaborn as sns
    import matplotlib.pyplot as plt
    import matplotlib as mpl
    import numpy as np
    from dautil import plotting
  2. Use the following function that helps plot the palettes:
    def plot_palette(ax, plotter, pal, i, label, ncol=1): n = len(pal) x = np.linspace(0.0, 1.0, n) y = np.arange(n) + i * n ax.scatter(x, y, c=x, cmap=mpl.colors.ListedColormap(list(pal)), s=200) plotter.plot(x,y, label=label) handles, labels = ax.get_legend_handles_labels() ...

Get Python Data Analysis Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.