Skip to content

Instantly share code, notes, and snippets.

import matplotlib.pyplot as plt
import matplotlib.colors as mcolors
def plot_colormap():
colors = dict(mcolors.BASE_COLORS, **mcolors.CSS4_COLORS)
# Sort colors by hue, saturation, value and name.
by_hsv = sorted((tuple(mcolors.rgb_to_hsv(mcolors.to_rgb(color))), name)
for name, color in colors.items())
sorted_names = [name for hsv, name in by_hsv]