{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1d0d41d3-463c-4c6f-aa65-38131bdf3ddb",
   "metadata": {
    "tags": [
     "hide"
    ]
   },
   "outputs": [],
   "source": [
    "import seaborn as sns\n",
    "sns.set_theme()\n",
    "sns.palettes._patch_colormap_display()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d2a0ae1e-a01e-49b3-a677-2b05a195990a",
   "metadata": {},
   "source": [
    "Return discrete samples from a continuous matplotlib colormap:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2b6a4ce9-6e4e-4b59-ada8-14ef8aef21d7",
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.mpl_palette(\"viridis\")"
   ]
  },
  {
   "cell_type": "raw",
   "id": "0ccc47b1-c969-46e2-93bb-b9eb5a2e2141",
   "metadata": {},
   "source": [
    "Return the continuous colormap instead; note how the extreme values are more intense:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a8a1bc5d-1d62-45c6-a53b-9fadb58f11c0",
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.mpl_palette(\"viridis\", as_cmap=True)"
   ]
  },
  {
   "cell_type": "raw",
   "id": "ff0d1a3b-8641-40c0-bb4b-c22b83ec9432",
   "metadata": {},
   "source": [
    "Return more colors:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8faef1d8-a1eb-4060-be10-377342c9bd1d",
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.mpl_palette(\"viridis\", 8)"
   ]
  },
  {
   "cell_type": "raw",
   "id": "612bf052-e888-411d-a2ea-6a742a78bc63",
   "metadata": {},
   "source": [
    "Return values from a qualitative colormap:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "74db95a8-4898-4f6c-a57d-c751af1dc7bf",
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.mpl_palette(\"Set2\")"
   ]
  },
  {
   "cell_type": "raw",
   "id": "918494bf-1b8e-4b00-8950-1bd73032dee1",
   "metadata": {},
   "source": [
    "Notice how the palette will only contain distinct colors and can be shorter than requested:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d97efa25-9050-4e28-b758-da6f43c9f963",
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.mpl_palette(\"Set2\", 10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f64ad118-e213-43cc-a714-98ed13cc3824",
   "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": 5
}
