{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": [
     "hide"
    ]
   },
   "outputs": [],
   "source": [
    "import seaborn as sns\n",
    "sns.set_theme()\n",
    "sns.palettes._patch_colormap_display()"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "Calling with no arguments returns all colors from the current default\n",
    "color cycle:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.color_palette()"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "Other variants on the seaborn categorical color palette can be referenced by name:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.color_palette(\"pastel\")"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "Return a specified number of evenly spaced hues in the \"HUSL\" system:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.color_palette(\"husl\", 9)"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "Return all unique colors in a categorical Color Brewer palette:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.color_palette(\"Set2\")"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "Return a diverging Color Brewer palette as a continuous colormap:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.color_palette(\"Spectral\", as_cmap=True)"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "Return one of the perceptually-uniform palettes included in seaborn as a discrete palette:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.color_palette(\"flare\")"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "Return one of the perceptually-uniform palettes included in seaborn as a continuous colormap:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.color_palette(\"flare\", as_cmap=True)"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "Return a customized cubehelix color palette:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.color_palette(\"ch:s=.25,rot=-.25\", as_cmap=True)"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "Return a light sequential gradient:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.color_palette(\"light:#5A9\", as_cmap=True)"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "Return a reversed dark sequential gradient:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.color_palette(\"dark:#5A9_r\", as_cmap=True)"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "Return a blend gradient between two endpoints:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.color_palette(\"blend:#7AB,#EDA\", as_cmap=True)"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "Use as a context manager to change the default qualitative color palette:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": [
     "hide"
    ]
   },
   "outputs": [],
   "source": [
    "x, y = list(range(10)), [0] * 10\n",
    "hue = list(map(str, x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "with sns.color_palette(\"Set3\"):\n",
    "    sns.relplot(x=x, y=y, hue=hue, s=500, legend=False, height=1.3, aspect=4)\n",
    "\n",
    "sns.relplot(x=x, y=y, hue=hue, s=500, legend=False, height=1.3, aspect=4)"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "See the underlying color values as hex codes:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": [
     "show-output"
    ]
   },
   "outputs": [],
   "source": [
    "print(sns.color_palette(\"pastel6\").as_hex())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "py310",
   "language": "python",
   "name": "py310"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
