From e644793f0ac2b1be178425f20f529121f37f29de Mon Sep 17 00:00:00 2001 From: Michael Waskom Date: Sun, 18 Sep 2022 20:26:27 -0400 Subject: [PATCH] Convert color palette docstrings to notebooks (#3034) * Convert color palette docstrings to notebooks and rerun all with py310 kernel * Add v0.12.1 release notes to index * Improve failure mode when ipywidgets is not involved * Update palettes docstrings * Remove all other doctest-style examples * Remove doctest-oriented testing infrastructure * Mention in release notes * Skip colormap patch test on matplotlib's where it's not relevant * Use more robust approach to mpl backcompat --- .github/workflows/ci.yaml | 5 +- Makefile | 3 - README.md | 6 +- doc/_docstrings/FacetGrid.ipynb | 6 +- doc/_docstrings/JointGrid.ipynb | 6 +- doc/_docstrings/PairGrid.ipynb | 6 +- doc/_docstrings/axes_style.ipynb | 6 +- doc/_docstrings/barplot.ipynb | 6 +- doc/_docstrings/blend_palette.ipynb | 103 +++++ doc/_docstrings/boxenplot.ipynb | 6 +- doc/_docstrings/boxplot.ipynb | 6 +- doc/_docstrings/catplot.ipynb | 6 +- doc/_docstrings/color_palette.ipynb | 171 +++++--- doc/_docstrings/countplot.ipynb | 6 +- doc/_docstrings/cubehelix_palette.ipynb | 229 +++++++++++ doc/_docstrings/dark_palette.ipynb | 139 +++++++ doc/_docstrings/displot.ipynb | 6 +- doc/_docstrings/diverging_palette.ipynb | 183 +++++++++ doc/_docstrings/ecdfplot.ipynb | 6 +- doc/_docstrings/histplot.ipynb | 6 +- doc/_docstrings/hls_palette.ipynb | 157 ++++++++ doc/_docstrings/husl_palette.ipynb | 157 ++++++++ doc/_docstrings/jointplot.ipynb | 6 +- doc/_docstrings/kdeplot.ipynb | 6 +- doc/_docstrings/light_palette.ipynb | 139 +++++++ doc/_docstrings/lineplot.ipynb | 6 +- doc/_docstrings/move_legend.ipynb | 6 +- doc/_docstrings/mpl_palette.ipynb | 139 +++++++ doc/_docstrings/objects.Area.ipynb | 6 +- doc/_docstrings/objects.Band.ipynb | 6 +- doc/_docstrings/objects.Bar.ipynb | 6 +- doc/_docstrings/objects.Bars.ipynb | 6 +- doc/_docstrings/objects.Dot.ipynb | 6 +- doc/_docstrings/objects.Dots.ipynb | 6 +- doc/_docstrings/objects.Line.ipynb | 6 +- doc/_docstrings/objects.Lines.ipynb | 6 +- doc/_docstrings/objects.Path.ipynb | 6 +- doc/_docstrings/objects.Paths.ipynb | 6 +- doc/_docstrings/objects.Plot.add.ipynb | 6 +- doc/_docstrings/objects.Plot.facet.ipynb | 6 +- doc/_docstrings/objects.Plot.label.ipynb | 6 +- doc/_docstrings/objects.Plot.layout.ipynb | 6 +- doc/_docstrings/objects.Plot.limit.ipynb | 6 +- doc/_docstrings/objects.Plot.on.ipynb | 6 +- doc/_docstrings/objects.Plot.pair.ipynb | 6 +- doc/_docstrings/objects.Plot.scale.ipynb | 6 +- doc/_docstrings/objects.Plot.share.ipynb | 6 +- doc/_docstrings/objects.Plot.theme.ipynb | 6 +- doc/_docstrings/objects.Range.ipynb | 6 +- doc/_docstrings/pairplot.ipynb | 6 +- doc/_docstrings/plotting_context.ipynb | 6 +- doc/_docstrings/pointplot.ipynb | 6 +- doc/_docstrings/relplot.ipynb | 6 +- doc/_docstrings/rugplot.ipynb | 6 +- doc/_docstrings/scatterplot.ipynb | 6 +- doc/_docstrings/set_context.ipynb | 6 +- doc/_docstrings/set_style.ipynb | 6 +- doc/_docstrings/set_theme.ipynb | 6 +- doc/_docstrings/stripplot.ipynb | 6 +- doc/_docstrings/swarmplot.ipynb | 6 +- doc/_docstrings/violinplot.ipynb | 6 +- doc/_tutorial/aesthetics.ipynb | 6 +- doc/_tutorial/axis_grids.ipynb | 6 +- doc/_tutorial/categorical.ipynb | 6 +- doc/_tutorial/color_palettes.ipynb | 6 +- doc/_tutorial/data_structure.ipynb | 6 +- doc/_tutorial/distributions.ipynb | 6 +- doc/_tutorial/error_bars.ipynb | 6 +- doc/_tutorial/function_overview.ipynb | 6 +- doc/_tutorial/introduction.ipynb | 6 +- doc/_tutorial/objects_interface.ipynb | 6 +- doc/_tutorial/properties.ipynb | 6 +- doc/_tutorial/regression.ipynb | 6 +- doc/_tutorial/relational.ipynb | 6 +- doc/whatsnew/index.rst | 1 + doc/whatsnew/v0.12.1.rst | 4 +- seaborn/palettes.py | 453 ++++++---------------- seaborn/rcmod.py | 6 - seaborn/widgets.py | 20 +- tests/test_palettes.py | 17 +- 80 files changed, 1711 insertions(+), 593 deletions(-) create mode 100644 doc/_docstrings/blend_palette.ipynb create mode 100644 doc/_docstrings/cubehelix_palette.ipynb create mode 100644 doc/_docstrings/dark_palette.ipynb create mode 100644 doc/_docstrings/diverging_palette.ipynb create mode 100644 doc/_docstrings/hls_palette.ipynb create mode 100644 doc/_docstrings/husl_palette.ipynb create mode 100644 doc/_docstrings/light_palette.ipynb create mode 100644 doc/_docstrings/mpl_palette.ipynb diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 980d6b93ad..852144c17d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -53,17 +53,14 @@ jobs: strategy: matrix: python: ["3.7", "3.8", "3.9", "3.10"] - target: [test] install: [full] deps: [latest] include: - python: "3.7" - target: unittests install: full deps: pinned - python: "3.10" - target: unittests install: light deps: latest @@ -83,7 +80,7 @@ jobs: pip install .[dev$EXTRAS] $DEPS - name: Run tests - run: make ${{ matrix.target }} + run: make test - name: Upload coverage uses: codecov/codecov-action@v2 diff --git a/Makefile b/Makefile index 073785f22b..0d2b7247a1 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,6 @@ export SHELL := /bin/bash test: - pytest -n auto --doctest-modules --cov=seaborn --cov=tests --cov-config=.coveragerc seaborn tests - -unittests: pytest -n auto --cov=seaborn --cov=tests --cov-config=.coveragerc tests lint: diff --git a/README.md b/README.md index fc2d963023..8b40b5f669 100644 --- a/README.md +++ b/README.md @@ -60,11 +60,9 @@ Testing Testing seaborn requires installing additional dependencies; they can be installed with the `dev` extra (e.g., `pip install .[dev]`). -To test the code, run `make test` in the source directory. This will exercise both the unit tests and docstring examples (using [pytest](https://docs.pytest.org/)) and generate a coverage report. +To test the code, run `make test` in the source directory. This will exercise the unit tests (using [pytest](https://docs.pytest.org/)) and generate a coverage report. -The doctests require a network connection (unless all example datasets are cached), but the unit tests can be run offline with `make unittests`. - -Code style is enforced with `flake8` using the settings in the [`setup.cfg`](./setup.cfg) file. Run `make lint` to check. Alternately, you can use `pre-commit` to automatically run lint checks on any files you are committing – just run `pre-commit install` to set it up, and then commit as usual going forward. +Code style is enforced with `flake8` using the settings in the [`setup.cfg`](./setup.cfg) file. Run `make lint` to check. Alternately, you can use `pre-commit` to automatically run lint checks on any files you are committing: just run `pre-commit install` to set it up, and then commit as usual going forward. Development ----------- diff --git a/doc/_docstrings/FacetGrid.ipynb b/doc/_docstrings/FacetGrid.ipynb index 7fc9b8146d..eeb329f2ce 100644 --- a/doc/_docstrings/FacetGrid.ipynb +++ b/doc/_docstrings/FacetGrid.ipynb @@ -280,9 +280,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -294,7 +294,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/JointGrid.ipynb b/doc/_docstrings/JointGrid.ipynb index 608529cfdf..ef8014aa0a 100644 --- a/doc/_docstrings/JointGrid.ipynb +++ b/doc/_docstrings/JointGrid.ipynb @@ -222,9 +222,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -236,7 +236,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/PairGrid.ipynb b/doc/_docstrings/PairGrid.ipynb index a5c54c8eab..c39af330e9 100644 --- a/doc/_docstrings/PairGrid.ipynb +++ b/doc/_docstrings/PairGrid.ipynb @@ -249,9 +249,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -263,7 +263,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/axes_style.ipynb b/doc/_docstrings/axes_style.ipynb index aedc546911..2dca0e87cf 100644 --- a/doc/_docstrings/axes_style.ipynb +++ b/doc/_docstrings/axes_style.ipynb @@ -80,9 +80,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -94,7 +94,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/barplot.ipynb b/doc/_docstrings/barplot.ipynb index 3a128a39c6..7b1264448d 100644 --- a/doc/_docstrings/barplot.ipynb +++ b/doc/_docstrings/barplot.ipynb @@ -103,9 +103,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -117,7 +117,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/blend_palette.ipynb b/doc/_docstrings/blend_palette.ipynb new file mode 100644 index 0000000000..85f8755a1c --- /dev/null +++ b/doc/_docstrings/blend_palette.ipynb @@ -0,0 +1,103 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "8f97280e-cec8-42b2-a968-4fd4364594f8", + "metadata": { + "tags": [ + "hide" + ] + }, + "outputs": [], + "source": [ + "import seaborn as sns\n", + "sns.set_theme()\n", + "sns.palettes._patch_colormap_display()" + ] + }, + { + "cell_type": "raw", + "id": "972edede-df1a-4010-9674-00b864d020e2", + "metadata": {}, + "source": [ + "Pass a list of two colors to interpolate between them:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e6ae2547-1042-4ac0-84ea-6f37a0229871", + "metadata": {}, + "outputs": [], + "source": [ + "sns.blend_palette([\"b\", \"r\"])" + ] + }, + { + "cell_type": "raw", + "id": "1d983eac-2dd5-4746-b27f-4dfa19b5e091", + "metadata": {}, + "source": [ + "The color list can be arbitrarily long, and any color format can be used:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "846b78fd-30ce-4507-93f4-4274122c1987", + "metadata": {}, + "outputs": [], + "source": [ + "sns.blend_palette([\"#45a872\", \".8\", \"xkcd:golden\"])" + ] + }, + { + "cell_type": "raw", + "id": "318fef32-1f83-44d9-9ff9-21fa0231b7c6", + "metadata": {}, + "source": [ + "Return a continuous colormap instead of a discrete palette:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f0a05bc3-c60b-47a1-b276-d2e28a4a8226", + "metadata": {}, + "outputs": [], + "source": [ + "sns.blend_palette([\"#bdc\", \"#7b9\", \"#47a\"], as_cmap=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0473a402-0ec2-4877-81d2-ed6c57aefc77", + "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.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/doc/_docstrings/boxenplot.ipynb b/doc/_docstrings/boxenplot.ipynb index 00176eb646..1b2f863b63 100644 --- a/doc/_docstrings/boxenplot.ipynb +++ b/doc/_docstrings/boxenplot.ipynb @@ -108,9 +108,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -122,7 +122,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/boxplot.ipynb b/doc/_docstrings/boxplot.ipynb index 1c6f5daf91..098cda1ac4 100644 --- a/doc/_docstrings/boxplot.ipynb +++ b/doc/_docstrings/boxplot.ipynb @@ -151,9 +151,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -165,7 +165,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/catplot.ipynb b/doc/_docstrings/catplot.ipynb index d4f01b6a67..ba956e6ab5 100644 --- a/doc/_docstrings/catplot.ipynb +++ b/doc/_docstrings/catplot.ipynb @@ -168,9 +168,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -182,7 +182,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/color_palette.ipynb b/doc/_docstrings/color_palette.ipynb index 2dcfc8f93f..a0408b429a 100644 --- a/doc/_docstrings/color_palette.ipynb +++ b/doc/_docstrings/color_palette.ipynb @@ -10,47 +10,9 @@ }, "outputs": [], "source": [ - "import seaborn as sns; sns.set_theme()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "tags": [ - "hide" - ] - }, - "outputs": [], - "source": [ - "# Add colormap display methods to matplotlib colormaps.\n", - "# These are forthcoming in matplotlib 3.4, but, the matplotlib display\n", - "# method includes the colormap name, which is redundant.\n", - "def _repr_png_(self):\n", - " \"\"\"Generate a PNG representation of the Colormap.\"\"\"\n", - " import io\n", - " from PIL import Image\n", - " import numpy as np\n", - " IMAGE_SIZE = (400, 50)\n", - " X = np.tile(np.linspace(0, 1, IMAGE_SIZE[0]), (IMAGE_SIZE[1], 1))\n", - " pixels = self(X, bytes=True)\n", - " png_bytes = io.BytesIO()\n", - " Image.fromarray(pixels).save(png_bytes, format='png')\n", - " return png_bytes.getvalue()\n", - " \n", - "def _repr_html_(self):\n", - " \"\"\"Generate an HTML representation of the Colormap.\"\"\"\n", - " import base64\n", - " png_bytes = self._repr_png_()\n", - " png_base64 = base64.b64encode(png_bytes).decode('ascii')\n", - " return ('')\n", - " \n", - "import matplotlib as mpl\n", - "mpl.colors.Colormap._repr_png_ = _repr_png_\n", - "mpl.colors.Colormap._repr_html_ = _repr_html_" + "import seaborn as sns\n", + "sns.set_theme()\n", + "sns.palettes._patch_colormap_display()" ] }, { @@ -122,7 +84,39 @@ "cell_type": "raw", "metadata": {}, "source": [ - "Return one of the perceptually-uniform colormaps included in seaborn:" + "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:" ] }, { @@ -154,7 +148,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "Return a light-themed sequential colormap to a seed color:" + "Return a light sequential gradient:" ] }, { @@ -166,6 +160,91 @@ "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, @@ -176,9 +255,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -190,7 +269,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/countplot.ipynb b/doc/_docstrings/countplot.ipynb index c0cdf8abdb..6205ac15c1 100644 --- a/doc/_docstrings/countplot.ipynb +++ b/doc/_docstrings/countplot.ipynb @@ -77,9 +77,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -91,7 +91,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/cubehelix_palette.ipynb b/doc/_docstrings/cubehelix_palette.ipynb new file mode 100644 index 0000000000..a48aab5aed --- /dev/null +++ b/doc/_docstrings/cubehelix_palette.ipynb @@ -0,0 +1,229 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "60aebc68-2c7c-4af5-a159-8421e1f94ba6", + "metadata": { + "tags": [ + "hide" + ] + }, + "outputs": [], + "source": [ + "import seaborn as sns\n", + "sns.set_theme()\n", + "sns.palettes._patch_colormap_display()" + ] + }, + { + "cell_type": "raw", + "id": "242b3d42-1f10-4da2-9ef9-af06f7fbd724", + "metadata": {}, + "source": [ + "Return a discrete palette with default parameters:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6526accb-9930-4e39-9f58-1ca2941c1c9d", + "metadata": {}, + "outputs": [], + "source": [ + "sns.cubehelix_palette()" + ] + }, + { + "cell_type": "raw", + "id": "887a40f0-d949-41fa-9a43-0ee246c9a077", + "metadata": {}, + "source": [ + "Increase the number of colors:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "02833290-b1ee-46df-a2a0-8268fba94628", + "metadata": {}, + "outputs": [], + "source": [ + "sns.cubehelix_palette(8)" + ] + }, + { + "cell_type": "raw", + "id": "a9eb86c7-f92e-4422-ae62-a2ef136e7e35", + "metadata": {}, + "source": [ + "Return a continuous colormap rather than a discrete palette:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a460efc2-cf0a-46bf-a12f-12870afce8a5", + "metadata": {}, + "outputs": [], + "source": [ + "sns.cubehelix_palette(as_cmap=True)" + ] + }, + { + "cell_type": "raw", + "id": "5b84aa6c-ad79-45b1-a7d2-44b7ecba5f7d", + "metadata": {}, + "source": [ + "Change the starting point of the helix:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "70ee079a-e760-4d43-8447-648fd236ab15", + "metadata": {}, + "outputs": [], + "source": [ + "sns.cubehelix_palette(start=2)" + ] + }, + { + "cell_type": "raw", + "id": "5e21fa22-9ac3-4354-8694-967f2447b286", + "metadata": {}, + "source": [ + "Change the amount of rotation in the helix:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ddb1b8c7-8933-4317-827f-4f10d2b4cecc", + "metadata": {}, + "outputs": [], + "source": [ + "sns.cubehelix_palette(rot=.2)" + ] + }, + { + "cell_type": "raw", + "id": "fa91aff7-54e7-4754-a13c-b629dfc33e8f", + "metadata": {}, + "source": [ + "Rotate in the reverse direction:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "548a3942-48ae-40d2-abb7-acc2ffd71601", + "metadata": {}, + "outputs": [], + "source": [ + "sns.cubehelix_palette(rot=-.2)" + ] + }, + { + "cell_type": "raw", + "id": "e7188a1b-183f-4b04-93a0-975c27fe408e", + "metadata": {}, + "source": [ + "Apply a nonlinearity to the luminance ramp:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9ced54ff-a396-451e-b17f-2366b56f920b", + "metadata": {}, + "outputs": [], + "source": [ + "sns.cubehelix_palette(gamma=.5)" + ] + }, + { + "cell_type": "raw", + "id": "bc82ce48-2df3-464e-b70e-a1d73d0432c6", + "metadata": {}, + "source": [ + "Increase the saturation of the colors:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a38b91a8-3fdc-4293-a3ea-71b4006cd2a1", + "metadata": {}, + "outputs": [], + "source": [ + "sns.cubehelix_palette(hue=1)" + ] + }, + { + "cell_type": "raw", + "id": "f8d23ba1-013a-489f-94c4-f2080bfdae87", + "metadata": {}, + "source": [ + "Change the luminance at the start and end points:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a4f05a16-18f0-4c14-99a4-57a0734aad02", + "metadata": {}, + "outputs": [], + "source": [ + "sns.cubehelix_palette(dark=.25, light=.75)" + ] + }, + { + "cell_type": "raw", + "id": "0bfcc5d9-05ba-4715-94ac-8d430d9416c2", + "metadata": {}, + "source": [ + "Reverse the direction of the luminance ramp:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "74563491-5448-42c3-86c5-f5d55ce6924c", + "metadata": {}, + "outputs": [], + "source": [ + "sns.cubehelix_palette(reverse=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "94a83211-8b8e-4e60-8365-9600e71ddc5d", + "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.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/doc/_docstrings/dark_palette.ipynb b/doc/_docstrings/dark_palette.ipynb new file mode 100644 index 0000000000..a4ed7adf43 --- /dev/null +++ b/doc/_docstrings/dark_palette.ipynb @@ -0,0 +1,139 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "5cd1cbb8-ba1a-460b-8e3a-bc285867f1d1", + "metadata": { + "tags": [ + "hide" + ] + }, + "outputs": [], + "source": [ + "import seaborn as sns\n", + "sns.set_theme()\n", + "sns.palettes._patch_colormap_display()" + ] + }, + { + "cell_type": "raw", + "id": "b157eb25-015f-4dd6-9785-83ba19cf4f94", + "metadata": {}, + "source": [ + "Define a sequential ramp from a dark gray to a specified color:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5b655d28-9855-4528-8b8e-a6c50288fd1b", + "metadata": {}, + "outputs": [], + "source": [ + "sns.dark_palette(\"seagreen\")" + ] + }, + { + "cell_type": "raw", + "id": "50053b26-112a-4378-8ef0-9be0fb565ec7", + "metadata": {}, + "source": [ + "Specify the color with a hex code:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "74ae0d17-f65b-4bcf-ae66-d97d46964d5c", + "metadata": {}, + "outputs": [], + "source": [ + "sns.dark_palette(\"#79C\")" + ] + }, + { + "cell_type": "raw", + "id": "eea376a2-fdf5-40e4-a187-3a28af529072", + "metadata": {}, + "source": [ + "Specify the color from the husl system:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "66e451ee-869a-41ea-8dc5-4240b11e7be5", + "metadata": {}, + "outputs": [], + "source": [ + "sns.dark_palette((20, 60, 50), input=\"husl\")" + ] + }, + { + "cell_type": "raw", + "id": "e4f44dcd-cf49-4920-ac05-b4db67870363", + "metadata": {}, + "source": [ + "Increase the number of colors:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "75985f07-de92-4d8b-89d5-caf445b9375e", + "metadata": {}, + "outputs": [], + "source": [ + "sns.dark_palette(\"xkcd:golden\", 8)" + ] + }, + { + "cell_type": "raw", + "id": "34687ae8-fd6d-427a-a639-208f19e61122", + "metadata": {}, + "source": [ + "Return a continuous colormap rather than a discrete palette:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2c342db4-7f97-40f5-934e-9a82201890d1", + "metadata": {}, + "outputs": [], + "source": [ + "sns.dark_palette(\"#b285bc\", as_cmap=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e7ebe64b-25fa-4c52-9ebe-fdcbba0ee51e", + "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.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/doc/_docstrings/displot.ipynb b/doc/_docstrings/displot.ipynb index 543aa7fb8c..1b2011fec0 100644 --- a/doc/_docstrings/displot.ipynb +++ b/doc/_docstrings/displot.ipynb @@ -217,9 +217,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -231,7 +231,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/diverging_palette.ipynb b/doc/_docstrings/diverging_palette.ipynb new file mode 100644 index 0000000000..c38196be98 --- /dev/null +++ b/doc/_docstrings/diverging_palette.ipynb @@ -0,0 +1,183 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "01295cb6-cc7a-4c6d-94cf-9b0e6cde9fa7", + "metadata": { + "tags": [ + "hide" + ] + }, + "outputs": [], + "source": [ + "import seaborn as sns\n", + "sns.set_theme()\n", + "sns.palettes._patch_colormap_display()" + ] + }, + { + "cell_type": "raw", + "id": "84880848-0805-4c41-999a-50808b397275", + "metadata": {}, + "source": [ + "Generate diverging ramps from blue to red through white:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "643b3e07-8365-46e3-b033-af7a2fdcd158", + "metadata": {}, + "outputs": [], + "source": [ + "sns.diverging_palette(240, 20)" + ] + }, + { + "cell_type": "raw", + "id": "5ae53941-d9d9-4b5a-8abc-173911ebee74", + "metadata": {}, + "source": [ + "Change the center color to be dark:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "41f03771-8fb2-46f6-93c5-5a0e28be625c", + "metadata": {}, + "outputs": [], + "source": [ + "sns.diverging_palette(240, 20, center=\"dark\")" + ] + }, + { + "cell_type": "raw", + "id": "0aeb2402-2cbe-4546-a354-f1f501f762ae", + "metadata": {}, + "source": [ + "Return a continuous colormap rather than a discrete palette:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "64d335a5-f8b2-433f-a83f-5aeff7db583a", + "metadata": {}, + "outputs": [], + "source": [ + "sns.diverging_palette(240, 20, as_cmap=True)" + ] + }, + { + "cell_type": "raw", + "id": "77223a07-8492-4056-a0f7-14e133e3ce2c", + "metadata": {}, + "source": [ + "Increase the amount of separation around the center value:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "82472c1e-4b16-40eb-be1d-480bbd2aa702", + "metadata": {}, + "outputs": [], + "source": [ + "sns.diverging_palette(240, 20, sep=30, as_cmap=True)" + ] + }, + { + "cell_type": "raw", + "id": "966e8594-b458-414c-a7b0-3e804ce407bf", + "metadata": {}, + "source": [ + "Use a magenta-to-green palette instead:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a03f8ede-b424-4e06-beb6-cf63c94bcd9e", + "metadata": {}, + "outputs": [], + "source": [ + "sns.diverging_palette(280, 150)" + ] + }, + { + "cell_type": "raw", + "id": "b3b17689-58e2-4065-9d52-1cf5ebcd4e89", + "metadata": {}, + "source": [ + "Decrease the saturation of the endpoints:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "02aaa009-f257-4fc7-a2de-40fbb1464490", + "metadata": {}, + "outputs": [], + "source": [ + "sns.diverging_palette(280, 150, s=50)" + ] + }, + { + "cell_type": "raw", + "id": "db75ca48-ba72-4ca2-8480-bc72c20a70cc", + "metadata": {}, + "source": [ + "Decrease the lightness of the endpoints:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "89e3bcb1-a17c-4465-830f-46043cb6c322", + "metadata": {}, + "outputs": [], + "source": [ + "sns.diverging_palette(280, 150, l=35)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4e42452a-a485-43e7-bbc3-338db58e4637", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e19f523f-c2f7-489a-ba00-326810e31a67", + "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.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/doc/_docstrings/ecdfplot.ipynb b/doc/_docstrings/ecdfplot.ipynb index 9eff8bd735..d95e517a1d 100644 --- a/doc/_docstrings/ecdfplot.ipynb +++ b/doc/_docstrings/ecdfplot.ipynb @@ -120,9 +120,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -134,7 +134,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/histplot.ipynb b/doc/_docstrings/histplot.ipynb index f3ed72e328..308d0db15e 100644 --- a/doc/_docstrings/histplot.ipynb +++ b/doc/_docstrings/histplot.ipynb @@ -461,9 +461,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -475,7 +475,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/hls_palette.ipynb b/doc/_docstrings/hls_palette.ipynb new file mode 100644 index 0000000000..03c95a248d --- /dev/null +++ b/doc/_docstrings/hls_palette.ipynb @@ -0,0 +1,157 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "158cd1cf-6b30-4054-b32f-a166fcb883be", + "metadata": { + "tags": [ + "hide" + ] + }, + "outputs": [], + "source": [ + "import seaborn as sns\n", + "sns.set_theme()\n", + "sns.palettes._patch_colormap_display()" + ] + }, + { + "cell_type": "raw", + "id": "c81b86cb-fb4e-418b-8d2f-6cd10601ac5a", + "metadata": {}, + "source": [ + "By default, return 6 colors with identical lightness and saturation and evenly-sampled hues:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6c3eaeaf-88eb-4012-96ea-41b328fa98b9", + "metadata": {}, + "outputs": [], + "source": [ + "sns.hls_palette()" + ] + }, + { + "cell_type": "raw", + "id": "f7624b0b-2311-45de-b6a5-fc07132ce455", + "metadata": {}, + "source": [ + "Increase the number of colors:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "555c29d1-6972-4a19-ad32-957fb7545634", + "metadata": {}, + "outputs": [], + "source": [ + "sns.hls_palette(8)" + ] + }, + { + "cell_type": "raw", + "id": "24713fa6-e485-4358-9ffc-d40bd9543caa", + "metadata": {}, + "source": [ + "Decrease the lightness:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b6f80b4c-f7b4-4deb-a119-cdf6cfe1f7b5", + "metadata": {}, + "outputs": [], + "source": [ + "sns.hls_palette(l=.3)" + ] + }, + { + "cell_type": "raw", + "id": "e521b514-5572-43e8-95ae-a20cc30169b8", + "metadata": {}, + "source": [ + "Decrease the saturation:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f88bd038-0c9c-48b1-92b0-d272a9c199f4", + "metadata": {}, + "outputs": [], + "source": [ + "sns.hls_palette(s=.3)" + ] + }, + { + "cell_type": "raw", + "id": "92a2212c-2177-4c82-8a5e-9dd788e9f87c", + "metadata": {}, + "source": [ + "Change the start-point for hue sampling:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f8da8fbc-551c-4896-b1b8-04203e740d78", + "metadata": {}, + "outputs": [], + "source": [ + "sns.hls_palette(h=.5)" + ] + }, + { + "cell_type": "raw", + "id": "87780608-1f5a-409f-b31f-6a31a599f122", + "metadata": {}, + "source": [ + "Return a continuous colormap. Notice the perceptual discontinuities, especially around yellow, cyan, and magenta: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4c622b3b-70d7-4139-8389-f3d0d4addd66", + "metadata": {}, + "outputs": [], + "source": [ + "sns.hls_palette(as_cmap=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3a83c1de-88c5-4327-abd2-19e8f3642052", + "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.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/doc/_docstrings/husl_palette.ipynb b/doc/_docstrings/husl_palette.ipynb new file mode 100644 index 0000000000..a933bb0496 --- /dev/null +++ b/doc/_docstrings/husl_palette.ipynb @@ -0,0 +1,157 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "a6794650-f28f-40eb-95a7-3f0e5c4b332d", + "metadata": { + "tags": [ + "hide" + ] + }, + "outputs": [], + "source": [ + "import seaborn as sns\n", + "sns.set_theme()\n", + "sns.palettes._patch_colormap_display()" + ] + }, + { + "cell_type": "raw", + "id": "fab2f86e-45d4-4982-ade7-0a5ea6d762d1", + "metadata": {}, + "source": [ + "By default, return 6 colors with identical lightness and saturation and evenly-sampled hues:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b220950e-0ca2-4101-b56a-14eebe8ee8d0", + "metadata": {}, + "outputs": [], + "source": [ + "sns.husl_palette()" + ] + }, + { + "cell_type": "raw", + "id": "c5e4a2e3-e6b8-42bf-be19-348ff7ae2798", + "metadata": {}, + "source": [ + "Increase the number of colors:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7d0af740-cfca-49fb-a472-1daa4ccb3f3a", + "metadata": {}, + "outputs": [], + "source": [ + "sns.husl_palette(8)" + ] + }, + { + "cell_type": "raw", + "id": "1a7189f2-2a26-446a-90e7-cf41dcac4f25", + "metadata": {}, + "source": [ + "Decrease the lightness:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "43af79c7-f497-41e5-874a-83eed99500f3", + "metadata": {}, + "outputs": [], + "source": [ + "sns.husl_palette(l=.4)" + ] + }, + { + "cell_type": "raw", + "id": "6d4099b7-5115-4365-b120-33a345581f5d", + "metadata": {}, + "source": [ + "Decrease the saturation:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "52c1afc7-d982-4199-b218-222aa94563c5", + "metadata": {}, + "outputs": [], + "source": [ + "sns.husl_palette(s=.4)" + ] + }, + { + "cell_type": "raw", + "id": "d26131ac-0d11-48c5-88b1-4e5cf9383000", + "metadata": {}, + "source": [ + "Change the start-point for hue sampling:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d72f06a0-13e0-47f7-bc70-4c5935eaa130", + "metadata": {}, + "outputs": [], + "source": [ + "sns.husl_palette(h=.5)" + ] + }, + { + "cell_type": "raw", + "id": "7e6c3c19-41d3-4315-b03e-909d201d0e76", + "metadata": {}, + "source": [ + "Return a continuous colormap:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "49c18838-0589-496f-9a61-635195c07f61", + "metadata": {}, + "outputs": [], + "source": [ + "sns.husl_palette(as_cmap=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c710a557-8e84-44cb-ab4c-baabcc4fd328", + "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.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/doc/_docstrings/jointplot.ipynb b/doc/_docstrings/jointplot.ipynb index 32801c3a3b..379b5307c8 100644 --- a/doc/_docstrings/jointplot.ipynb +++ b/doc/_docstrings/jointplot.ipynb @@ -172,9 +172,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -186,7 +186,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/kdeplot.ipynb b/doc/_docstrings/kdeplot.ipynb index 81d375a7b3..40693d05b4 100644 --- a/doc/_docstrings/kdeplot.ipynb +++ b/doc/_docstrings/kdeplot.ipynb @@ -327,9 +327,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -341,7 +341,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/light_palette.ipynb b/doc/_docstrings/light_palette.ipynb new file mode 100644 index 0000000000..a1a830a3d9 --- /dev/null +++ b/doc/_docstrings/light_palette.ipynb @@ -0,0 +1,139 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "5cd1cbb8-ba1a-460b-8e3a-bc285867f1d1", + "metadata": { + "tags": [ + "hide" + ] + }, + "outputs": [], + "source": [ + "import seaborn as sns\n", + "sns.set_theme()\n", + "sns.palettes._patch_colormap_display()" + ] + }, + { + "cell_type": "raw", + "id": "b157eb25-015f-4dd6-9785-83ba19cf4f94", + "metadata": {}, + "source": [ + "Define a sequential ramp from a light gray to a specified color:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "851a4742-6276-4383-b17e-480beb896877", + "metadata": {}, + "outputs": [], + "source": [ + "sns.light_palette(\"seagreen\")" + ] + }, + { + "cell_type": "raw", + "id": "50053b26-112a-4378-8ef0-9be0fb565ec7", + "metadata": {}, + "source": [ + "Specify the color with a hex code:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "74ae0d17-f65b-4bcf-ae66-d97d46964d5c", + "metadata": {}, + "outputs": [], + "source": [ + "sns.light_palette(\"#79C\")" + ] + }, + { + "cell_type": "raw", + "id": "eea376a2-fdf5-40e4-a187-3a28af529072", + "metadata": {}, + "source": [ + "Specify the color from the husl system:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "66e451ee-869a-41ea-8dc5-4240b11e7be5", + "metadata": {}, + "outputs": [], + "source": [ + "sns.light_palette((20, 60, 50), input=\"husl\")" + ] + }, + { + "cell_type": "raw", + "id": "e4f44dcd-cf49-4920-ac05-b4db67870363", + "metadata": {}, + "source": [ + "Increase the number of colors:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "75985f07-de92-4d8b-89d5-caf445b9375e", + "metadata": {}, + "outputs": [], + "source": [ + "sns.light_palette(\"xkcd:copper\", 8)" + ] + }, + { + "cell_type": "raw", + "id": "34687ae8-fd6d-427a-a639-208f19e61122", + "metadata": {}, + "source": [ + "Return a continuous colormap rather than a discrete palette:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2c342db4-7f97-40f5-934e-9a82201890d1", + "metadata": {}, + "outputs": [], + "source": [ + "sns.light_palette(\"#a275ac\", as_cmap=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e7ebe64b-25fa-4c52-9ebe-fdcbba0ee51e", + "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.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/doc/_docstrings/lineplot.ipynb b/doc/_docstrings/lineplot.ipynb index 02b20c73d2..2d73607415 100644 --- a/doc/_docstrings/lineplot.ipynb +++ b/doc/_docstrings/lineplot.ipynb @@ -431,9 +431,9 @@ "hash": "8bdfc9d9da1e36addfcfc8a3409187c45d33387af0f87d0d91e99e8d6403f1c3" }, "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -445,7 +445,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/move_legend.ipynb b/doc/_docstrings/move_legend.ipynb index 604eda0b3a..f36848cf54 100644 --- a/doc/_docstrings/move_legend.ipynb +++ b/doc/_docstrings/move_legend.ipynb @@ -134,9 +134,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -148,7 +148,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/mpl_palette.ipynb b/doc/_docstrings/mpl_palette.ipynb new file mode 100644 index 0000000000..d878fcc9ec --- /dev/null +++ b/doc/_docstrings/mpl_palette.ipynb @@ -0,0 +1,139 @@ +{ + "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.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/doc/_docstrings/objects.Area.ipynb b/doc/_docstrings/objects.Area.ipynb index f3ddc6aefd..256b46a93f 100644 --- a/doc/_docstrings/objects.Area.ipynb +++ b/doc/_docstrings/objects.Area.ipynb @@ -139,9 +139,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -153,7 +153,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/objects.Band.ipynb b/doc/_docstrings/objects.Band.ipynb index 902e33a3aa..5419a1935d 100644 --- a/doc/_docstrings/objects.Band.ipynb +++ b/doc/_docstrings/objects.Band.ipynb @@ -97,9 +97,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -111,7 +111,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/objects.Bar.ipynb b/doc/_docstrings/objects.Bar.ipynb index 30ac8ece4b..1ca0851975 100644 --- a/doc/_docstrings/objects.Bar.ipynb +++ b/doc/_docstrings/objects.Bar.ipynb @@ -164,9 +164,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -178,7 +178,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/objects.Bars.ipynb b/doc/_docstrings/objects.Bars.ipynb index eb47550ab6..71969df4b3 100644 --- a/doc/_docstrings/objects.Bars.ipynb +++ b/doc/_docstrings/objects.Bars.ipynb @@ -143,9 +143,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -157,7 +157,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/objects.Dot.ipynb b/doc/_docstrings/objects.Dot.ipynb index 34a262bcef..d133c04127 100644 --- a/doc/_docstrings/objects.Dot.ipynb +++ b/doc/_docstrings/objects.Dot.ipynb @@ -168,9 +168,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -182,7 +182,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/objects.Dots.ipynb b/doc/_docstrings/objects.Dots.ipynb index a7f920fa43..f1b3a53d2c 100644 --- a/doc/_docstrings/objects.Dots.ipynb +++ b/doc/_docstrings/objects.Dots.ipynb @@ -124,9 +124,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -138,7 +138,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/objects.Line.ipynb b/doc/_docstrings/objects.Line.ipynb index 27c140913a..bc8b8b5ec3 100644 --- a/doc/_docstrings/objects.Line.ipynb +++ b/doc/_docstrings/objects.Line.ipynb @@ -146,9 +146,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -160,7 +160,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/objects.Lines.ipynb b/doc/_docstrings/objects.Lines.ipynb index ccce6c28ae..375715636d 100644 --- a/doc/_docstrings/objects.Lines.ipynb +++ b/doc/_docstrings/objects.Lines.ipynb @@ -75,9 +75,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -89,7 +89,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/objects.Path.ipynb b/doc/_docstrings/objects.Path.ipynb index 1b9a440013..39b4a2b78a 100644 --- a/doc/_docstrings/objects.Path.ipynb +++ b/doc/_docstrings/objects.Path.ipynb @@ -64,9 +64,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -78,7 +78,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/objects.Paths.ipynb b/doc/_docstrings/objects.Paths.ipynb index 0f67ab75ee..5d9d33990e 100644 --- a/doc/_docstrings/objects.Paths.ipynb +++ b/doc/_docstrings/objects.Paths.ipynb @@ -81,9 +81,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -95,7 +95,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/objects.Plot.add.ipynb b/doc/_docstrings/objects.Plot.add.ipynb index 3f9089982e..e997aca980 100644 --- a/doc/_docstrings/objects.Plot.add.ipynb +++ b/doc/_docstrings/objects.Plot.add.ipynb @@ -196,9 +196,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -210,7 +210,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/objects.Plot.facet.ipynb b/doc/_docstrings/objects.Plot.facet.ipynb index dbded39a7c..2155dfb5ec 100644 --- a/doc/_docstrings/objects.Plot.facet.ipynb +++ b/doc/_docstrings/objects.Plot.facet.ipynb @@ -200,9 +200,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -214,7 +214,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/objects.Plot.label.ipynb b/doc/_docstrings/objects.Plot.label.ipynb index 5d9d0b6be8..3a4300b3e3 100644 --- a/doc/_docstrings/objects.Plot.label.ipynb +++ b/doc/_docstrings/objects.Plot.label.ipynb @@ -139,9 +139,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -153,7 +153,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/objects.Plot.layout.ipynb b/doc/_docstrings/objects.Plot.layout.ipynb index 53e60c0e58..1198766365 100644 --- a/doc/_docstrings/objects.Plot.layout.ipynb +++ b/doc/_docstrings/objects.Plot.layout.ipynb @@ -80,9 +80,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -94,7 +94,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/objects.Plot.limit.ipynb b/doc/_docstrings/objects.Plot.limit.ipynb index cf7ec4a1b0..9d8f33cfa7 100644 --- a/doc/_docstrings/objects.Plot.limit.ipynb +++ b/doc/_docstrings/objects.Plot.limit.ipynb @@ -98,9 +98,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -112,7 +112,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/objects.Plot.on.ipynb b/doc/_docstrings/objects.Plot.on.ipynb index 5596c7b107..7e14557bc0 100644 --- a/doc/_docstrings/objects.Plot.on.ipynb +++ b/doc/_docstrings/objects.Plot.on.ipynb @@ -160,9 +160,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -174,7 +174,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/objects.Plot.pair.ipynb b/doc/_docstrings/objects.Plot.pair.ipynb index b917a90fcd..fc78cbf175 100644 --- a/doc/_docstrings/objects.Plot.pair.ipynb +++ b/doc/_docstrings/objects.Plot.pair.ipynb @@ -195,9 +195,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -209,7 +209,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/objects.Plot.scale.ipynb b/doc/_docstrings/objects.Plot.scale.ipynb index 9bf784263e..d2d679f429 100644 --- a/doc/_docstrings/objects.Plot.scale.ipynb +++ b/doc/_docstrings/objects.Plot.scale.ipynb @@ -294,9 +294,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -308,7 +308,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/objects.Plot.share.ipynb b/doc/_docstrings/objects.Plot.share.ipynb index d26ecd0862..d0b1ef5cb1 100644 --- a/doc/_docstrings/objects.Plot.share.ipynb +++ b/doc/_docstrings/objects.Plot.share.ipynb @@ -109,9 +109,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -123,7 +123,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/objects.Plot.theme.ipynb b/doc/_docstrings/objects.Plot.theme.ipynb index 01eae3eca7..bb459a5620 100644 --- a/doc/_docstrings/objects.Plot.theme.ipynb +++ b/doc/_docstrings/objects.Plot.theme.ipynb @@ -125,9 +125,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -139,7 +139,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/objects.Range.ipynb b/doc/_docstrings/objects.Range.ipynb index 40725f3825..f8e03e3cc9 100644 --- a/doc/_docstrings/objects.Range.ipynb +++ b/doc/_docstrings/objects.Range.ipynb @@ -100,9 +100,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -114,7 +114,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/pairplot.ipynb b/doc/_docstrings/pairplot.ipynb index dd91f3638b..67948e4f9b 100644 --- a/doc/_docstrings/pairplot.ipynb +++ b/doc/_docstrings/pairplot.ipynb @@ -203,9 +203,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -217,7 +217,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/plotting_context.ipynb b/doc/_docstrings/plotting_context.ipynb index 48f65bc23a..4f757331a8 100644 --- a/doc/_docstrings/plotting_context.ipynb +++ b/doc/_docstrings/plotting_context.ipynb @@ -88,9 +88,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -102,7 +102,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/pointplot.ipynb b/doc/_docstrings/pointplot.ipynb index a4541bbd32..e58aeec19a 100644 --- a/doc/_docstrings/pointplot.ipynb +++ b/doc/_docstrings/pointplot.ipynb @@ -120,9 +120,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -134,7 +134,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/relplot.ipynb b/doc/_docstrings/relplot.ipynb index 9e782b756c..a7b36f1a44 100644 --- a/doc/_docstrings/relplot.ipynb +++ b/doc/_docstrings/relplot.ipynb @@ -240,9 +240,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -254,7 +254,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/rugplot.ipynb b/doc/_docstrings/rugplot.ipynb index 0819e2061c..4092dab06b 100644 --- a/doc/_docstrings/rugplot.ipynb +++ b/doc/_docstrings/rugplot.ipynb @@ -115,9 +115,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -129,7 +129,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/scatterplot.ipynb b/doc/_docstrings/scatterplot.ipynb index 4b51829f44..315a54845b 100644 --- a/doc/_docstrings/scatterplot.ipynb +++ b/doc/_docstrings/scatterplot.ipynb @@ -285,9 +285,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -299,7 +299,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/set_context.ipynb b/doc/_docstrings/set_context.ipynb index 882d577bab..07a5c091d4 100644 --- a/doc/_docstrings/set_context.ipynb +++ b/doc/_docstrings/set_context.ipynb @@ -82,9 +82,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -96,7 +96,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/set_style.ipynb b/doc/_docstrings/set_style.ipynb index 8f7f7b545d..25cdde23d6 100644 --- a/doc/_docstrings/set_style.ipynb +++ b/doc/_docstrings/set_style.ipynb @@ -63,9 +63,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -77,7 +77,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/set_theme.ipynb b/doc/_docstrings/set_theme.ipynb index 8b09f43936..add6eb2886 100644 --- a/doc/_docstrings/set_theme.ipynb +++ b/doc/_docstrings/set_theme.ipynb @@ -139,9 +139,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -153,7 +153,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/stripplot.ipynb b/doc/_docstrings/stripplot.ipynb index 34264355a7..d33034b5ba 100644 --- a/doc/_docstrings/stripplot.ipynb +++ b/doc/_docstrings/stripplot.ipynb @@ -291,9 +291,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -305,7 +305,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/swarmplot.ipynb b/doc/_docstrings/swarmplot.ipynb index 87b1eb653a..e90ee52115 100644 --- a/doc/_docstrings/swarmplot.ipynb +++ b/doc/_docstrings/swarmplot.ipynb @@ -263,9 +263,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -277,7 +277,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_docstrings/violinplot.ipynb b/doc/_docstrings/violinplot.ipynb index cbb4a8b10f..ebf5c4d963 100644 --- a/doc/_docstrings/violinplot.ipynb +++ b/doc/_docstrings/violinplot.ipynb @@ -171,9 +171,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -185,7 +185,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_tutorial/aesthetics.ipynb b/doc/_tutorial/aesthetics.ipynb index ecd78c0763..46f55d83ac 100644 --- a/doc/_tutorial/aesthetics.ipynb +++ b/doc/_tutorial/aesthetics.ipynb @@ -404,9 +404,9 @@ "metadata": { "celltoolbar": "Tags", "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -418,7 +418,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_tutorial/axis_grids.ipynb b/doc/_tutorial/axis_grids.ipynb index 051e4efcb6..2c3aacdc24 100644 --- a/doc/_tutorial/axis_grids.ipynb +++ b/doc/_tutorial/axis_grids.ipynb @@ -531,9 +531,9 @@ "metadata": { "celltoolbar": "Tags", "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -545,7 +545,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_tutorial/categorical.ipynb b/doc/_tutorial/categorical.ipynb index 7af75e398c..a1faa86a4f 100644 --- a/doc/_tutorial/categorical.ipynb +++ b/doc/_tutorial/categorical.ipynb @@ -520,9 +520,9 @@ "metadata": { "celltoolbar": "Tags", "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -534,7 +534,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_tutorial/color_palettes.ipynb b/doc/_tutorial/color_palettes.ipynb index 70afb7bf18..48cb84640f 100644 --- a/doc/_tutorial/color_palettes.ipynb +++ b/doc/_tutorial/color_palettes.ipynb @@ -982,9 +982,9 @@ "metadata": { "celltoolbar": "Tags", "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -996,7 +996,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_tutorial/data_structure.ipynb b/doc/_tutorial/data_structure.ipynb index 754460aebd..be7d55a026 100644 --- a/doc/_tutorial/data_structure.ipynb +++ b/doc/_tutorial/data_structure.ipynb @@ -475,9 +475,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -489,7 +489,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_tutorial/distributions.ipynb b/doc/_tutorial/distributions.ipynb index 5c1dca9ed8..7e47442b49 100644 --- a/doc/_tutorial/distributions.ipynb +++ b/doc/_tutorial/distributions.ipynb @@ -836,9 +836,9 @@ "metadata": { "celltoolbar": "Tags", "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -850,7 +850,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_tutorial/error_bars.ipynb b/doc/_tutorial/error_bars.ipynb index d8525ea842..1d34b35c75 100644 --- a/doc/_tutorial/error_bars.ipynb +++ b/doc/_tutorial/error_bars.ipynb @@ -347,9 +347,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -361,7 +361,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_tutorial/function_overview.ipynb b/doc/_tutorial/function_overview.ipynb index 08d69cea24..5096ca02e4 100644 --- a/doc/_tutorial/function_overview.ipynb +++ b/doc/_tutorial/function_overview.ipynb @@ -474,9 +474,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -488,7 +488,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_tutorial/introduction.ipynb b/doc/_tutorial/introduction.ipynb index 0955c375d5..c3f74f0fcf 100644 --- a/doc/_tutorial/introduction.ipynb +++ b/doc/_tutorial/introduction.ipynb @@ -447,9 +447,9 @@ "metadata": { "celltoolbar": "Tags", "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -461,7 +461,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_tutorial/objects_interface.ipynb b/doc/_tutorial/objects_interface.ipynb index 14bcd9c8f4..d5a0700ef1 100644 --- a/doc/_tutorial/objects_interface.ipynb +++ b/doc/_tutorial/objects_interface.ipynb @@ -1057,9 +1057,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -1071,7 +1071,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_tutorial/properties.ipynb b/doc/_tutorial/properties.ipynb index 36501bf819..d268243322 100644 --- a/doc/_tutorial/properties.ipynb +++ b/doc/_tutorial/properties.ipynb @@ -949,9 +949,9 @@ ], "metadata": { "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -963,7 +963,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_tutorial/regression.ipynb b/doc/_tutorial/regression.ipynb index d08fdbec76..72e7c68667 100644 --- a/doc/_tutorial/regression.ipynb +++ b/doc/_tutorial/regression.ipynb @@ -432,9 +432,9 @@ "metadata": { "celltoolbar": "Tags", "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -446,7 +446,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/_tutorial/relational.ipynb b/doc/_tutorial/relational.ipynb index face989a7f..4d8fb5f6b1 100644 --- a/doc/_tutorial/relational.ipynb +++ b/doc/_tutorial/relational.ipynb @@ -663,9 +663,9 @@ "metadata": { "celltoolbar": "Tags", "kernelspec": { - "display_name": "seaborn-py39-latest", + "display_name": "py310", "language": "python", - "name": "seaborn-py39-latest" + "name": "py310" }, "language_info": { "codemirror_mode": { @@ -677,7 +677,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.0" } }, "nbformat": 4, diff --git a/doc/whatsnew/index.rst b/doc/whatsnew/index.rst index 41b0a23cd1..82b2a9aed7 100644 --- a/doc/whatsnew/index.rst +++ b/doc/whatsnew/index.rst @@ -8,6 +8,7 @@ v0.12 .. toctree:: :maxdepth: 2 + v0.12.1 v0.12.0 v0.11 diff --git a/doc/whatsnew/v0.12.1.rst b/doc/whatsnew/v0.12.1.rst index 7ce5da4878..7060fc9dc5 100644 --- a/doc/whatsnew/v0.12.1.rst +++ b/doc/whatsnew/v0.12.1.rst @@ -2,4 +2,6 @@ v0.12.1 (Unreleased) -------------------- -- |Fix| Make :class:`objects.PolyFit` robust to missing data (:pr:`3010`). \ No newline at end of file +- |Fix| Make :class:`objects.PolyFit` robust to missing data (:pr:`3010`). + +- |Build| Seaborn no longer contains doctest-style examples, simplifying the testing infrastructure (:pr:`3034`). diff --git a/seaborn/palettes.py b/seaborn/palettes.py index 9b0fd58ce1..3306b0f2e9 100644 --- a/seaborn/palettes.py +++ b/seaborn/palettes.py @@ -91,6 +91,34 @@ def _repr_html_(self): return html +def _patch_colormap_display(): + """Simplify the rich display of matplotlib color maps in a notebook.""" + def _repr_png_(self): + """Generate a PNG representation of the Colormap.""" + import io + from PIL import Image + import numpy as np + IMAGE_SIZE = (400, 50) + X = np.tile(np.linspace(0, 1, IMAGE_SIZE[0]), (IMAGE_SIZE[1], 1)) + pixels = self(X, bytes=True) + png_bytes = io.BytesIO() + Image.fromarray(pixels).save(png_bytes, format='png') + return png_bytes.getvalue() + + def _repr_html_(self): + """Generate an HTML representation of the Colormap.""" + import base64 + png_bytes = self._repr_png_() + png_base64 = base64.b64encode(png_bytes).decode('ascii') + return ('') + + mpl.colors.Colormap._repr_png_ = _repr_png_ + mpl.colors.Colormap._repr_html_ = _repr_html_ + + def color_palette(palette=None, n_colors=None, desat=None, as_cmap=False): """Return a list of colors or continuous colormap defining a palette. @@ -125,11 +153,11 @@ def color_palette(palette=None, n_colors=None, desat=None, as_cmap=False): desat : float, optional Proportion to desaturate each color by. as_cmap : bool - If True, return a :class:`matplotlib.colors.Colormap`. + If True, return a :class:`matplotlib.colors.ListedColormap`. Returns ------- - list of RGB tuples or :class:`matplotlib.colors.Colormap` + list of RGB tuples or :class:`matplotlib.colors.ListedColormap` See Also -------- @@ -228,25 +256,36 @@ def color_palette(palette=None, n_colors=None, desat=None, as_cmap=False): def hls_palette(n_colors=6, h=.01, l=.6, s=.65, as_cmap=False): # noqa - """Get a set of evenly spaced colors in HLS hue space. + """ + Return hues with constant lightness and saturation in the HLS system. + + The hues are evenly sampled along a circular path. The resulting palette will be + appropriate for categorical or cyclical data. - h, l, and s should be between 0 and 1 + The `h`, `l`, and `s` values should be between 0 and 1. + + .. note:: + While the separation of the resulting colors will be mathematically + constant, the HLS system does not construct a perceptually-uniform space, + so their apparent intensity will vary. Parameters ---------- - n_colors : int - number of colors in the palette + Number of colors in the palette. h : float - first hue + The value of the first hue. l : float - lightness + The lightness value. s : float - saturation + The saturation intensity. + as_cmap : bool + If True, return a matplotlib colormap object. Returns ------- - list of RGB tuples or :class:`matplotlib.colors.Colormap` + palette + list of RGB tuples or :class:`matplotlib.colors.ListedColormap` See Also -------- @@ -254,35 +293,7 @@ def hls_palette(n_colors=6, h=.01, l=.6, s=.65, as_cmap=False): # noqa Examples -------- - - Create a palette of 10 colors with the default parameters: - - .. plot:: - :context: close-figs - - >>> import seaborn as sns; sns.set_theme() - >>> sns.palplot(sns.hls_palette(10)) - - Create a palette of 10 colors that begins at a different hue value: - - .. plot:: - :context: close-figs - - >>> sns.palplot(sns.hls_palette(10, h=.5)) - - Create a palette of 10 colors that are darker than the default: - - .. plot:: - :context: close-figs - - >>> sns.palplot(sns.hls_palette(10, l=.4)) - - Create a palette of 10 colors that are less saturated than the default: - - .. plot:: - :context: close-figs - - >>> sns.palplot(sns.hls_palette(10, s=.4)) + .. include:: ../docstrings/hls_palette.rst """ if as_cmap: @@ -299,62 +310,42 @@ def hls_palette(n_colors=6, h=.01, l=.6, s=.65, as_cmap=False): # noqa def husl_palette(n_colors=6, h=.01, s=.9, l=.65, as_cmap=False): # noqa - """Get a set of evenly spaced colors in HUSL hue space. + """ + Return hues with constant lightness and saturation in the HUSL system. - h, s, and l should be between 0 and 1 + The hues are evenly sampled along a circular path. The resulting palette will be + appropriate for categorical or cyclical data. + + The `h`, `l`, and `s` values should be between 0 and 1. + + This function is similar to :func:`hls_palette`, but it uses a nonlinear color + space that is more perceptually uniform. Parameters ---------- - n_colors : int - number of colors in the palette + Number of colors in the palette. h : float - first hue - s : float - saturation + The value of the first hue. l : float - lightness + The lightness value. + s : float + The saturation intensity. + as_cmap : bool + If True, return a matplotlib colormap object. Returns ------- - list of RGB tuples or :class:`matplotlib.colors.Colormap` + palette + list of RGB tuples or :class:`matplotlib.colors.ListedColormap` See Also -------- - hls_palette : Make a palette using evently spaced circular hues in the - HSL system. + hls_palette : Make a palette using evenly spaced hues in the HSL system. Examples -------- - - Create a palette of 10 colors with the default parameters: - - .. plot:: - :context: close-figs - - >>> import seaborn as sns; sns.set_theme() - >>> sns.palplot(sns.husl_palette(10)) - - Create a palette of 10 colors that begins at a different hue value: - - .. plot:: - :context: close-figs - - >>> sns.palplot(sns.husl_palette(10, h=.5)) - - Create a palette of 10 colors that are darker than the default: - - .. plot:: - :context: close-figs - - >>> sns.palplot(sns.husl_palette(10, l=.4)) - - Create a palette of 10 colors that are less saturated than the default: - - .. plot:: - :context: close-figs - - >>> sns.palplot(sns.husl_palette(10, s=.4)) + .. include:: ../docstrings/husl_palette.rst """ if as_cmap: @@ -373,17 +364,16 @@ def husl_palette(n_colors=6, h=.01, s=.9, l=.65, as_cmap=False): # noqa def mpl_palette(name, n_colors=6, as_cmap=False): - """Return discrete colors from a matplotlib palette. + """ + Return a palette or colormap from the matplotlib registry. - Note that this handles the qualitative colorbrewer palettes - properly, although if you ask for more colors than a particular - qualitative palette can provide you will get fewer than you are - expecting. In contrast, asking for qualitative color brewer palettes - using :func:`color_palette` will return the expected number of colors, - but they will cycle. + For continuous palettes, evenly-spaced discrete samples are chosen while + excluding the minimum and maximum value in the colormap to provide better + contrast at the extremes. - If you are using the IPython notebook, you can also use the function - :func:`choose_colorbrewer_palette` to interactively select palettes. + For qualitative palettes (e.g. those from colorbrewer), exact values are + indexed (rather than interpolated), but fewer than `n_colors` can be returned + if the palette does not define that many. Parameters ---------- @@ -394,39 +384,11 @@ def mpl_palette(name, n_colors=6, as_cmap=False): Returns ------- - list of RGB tuples or :class:`matplotlib.colors.Colormap` + list of RGB tuples or :class:`matplotlib.colors.ListedColormap` Examples -------- - - Create a qualitative colorbrewer palette with 8 colors: - - .. plot:: - :context: close-figs - - >>> import seaborn as sns; sns.set_theme() - >>> sns.palplot(sns.mpl_palette("Set2", 8)) - - Create a sequential colorbrewer palette: - - .. plot:: - :context: close-figs - - >>> sns.palplot(sns.mpl_palette("Blues")) - - Create a diverging palette: - - .. plot:: - :context: close-figs - - >>> sns.palplot(sns.mpl_palette("seismic", 8)) - - Create a "dark" sequential palette: - - .. plot:: - :context: close-figs - - >>> sns.palplot(sns.mpl_palette("GnBu_d")) + .. include: ../docstrings/mpl_palette.rst """ if name.endswith("_d"): @@ -491,14 +453,15 @@ def dark_palette(color, n_colors=6, reverse=False, as_cmap=False, input="rgb"): reverse : bool, optional if True, reverse the direction of the blend as_cmap : bool, optional - If True, return a :class:`matplotlib.colors.Colormap`. + If True, return a :class:`matplotlib.colors.ListedColormap`. input : {'rgb', 'hls', 'husl', xkcd'} Color space to interpret the input color. The first three options apply to tuple inputs and the latter applies to string inputs. Returns ------- - list of RGB tuples or :class:`matplotlib.colors.Colormap` + palette + list of RGB tuples or :class:`matplotlib.colors.ListedColormap` See Also -------- @@ -507,38 +470,7 @@ def dark_palette(color, n_colors=6, reverse=False, as_cmap=False, input="rgb"): Examples -------- - - Generate a palette from an HTML color: - - .. plot:: - :context: close-figs - - >>> import seaborn as sns; sns.set_theme() - >>> sns.palplot(sns.dark_palette("purple")) - - Generate a palette that decreases in lightness: - - .. plot:: - :context: close-figs - - >>> sns.palplot(sns.dark_palette("seagreen", reverse=True)) - - Generate a palette from an HUSL-space seed: - - .. plot:: - :context: close-figs - - >>> sns.palplot(sns.dark_palette((260, 75, 60), input="husl")) - - Generate a colormap object: - - .. plot:: - :context: close-figs - - >>> from numpy import arange - >>> x = arange(25).reshape(5, 5) - >>> cmap = sns.dark_palette("#2ecc71", as_cmap=True) - >>> ax = sns.heatmap(x, cmap=cmap) + .. include:: ../docstrings/dark_palette.rst """ rgb = _color_to_rgb(color, input) @@ -552,34 +484,32 @@ def dark_palette(color, n_colors=6, reverse=False, as_cmap=False, input="rgb"): def light_palette(color, n_colors=6, reverse=False, as_cmap=False, input="rgb"): """Make a sequential palette that blends from light to ``color``. - This kind of palette is good for data that range between relatively - uninteresting low values and interesting high values. - The ``color`` parameter can be specified in a number of ways, including all options for defining a color in matplotlib and several additional color spaces that are handled by seaborn. You can also use the database of named colors from the XKCD color survey. - If you are using the IPython notebook, you can also choose this palette + If you are using a Jupyter notebook, you can also choose this palette interactively with the :func:`choose_light_palette` function. Parameters ---------- color : base color for high values - hex code, html color name, or tuple in ``input`` space. + hex code, html color name, or tuple in `input` space. n_colors : int, optional number of colors in the palette reverse : bool, optional if True, reverse the direction of the blend as_cmap : bool, optional - If True, return a :class:`matplotlib.colors.Colormap`. + If True, return a :class:`matplotlib.colors.ListedColormap`. input : {'rgb', 'hls', 'husl', xkcd'} Color space to interpret the input color. The first three options apply to tuple inputs and the latter applies to string inputs. Returns ------- - list of RGB tuples or :class:`matplotlib.colors.Colormap` + palette + list of RGB tuples or :class:`matplotlib.colors.ListedColormap` See Also -------- @@ -588,38 +518,7 @@ def light_palette(color, n_colors=6, reverse=False, as_cmap=False, input="rgb"): Examples -------- - - Generate a palette from an HTML color: - - .. plot:: - :context: close-figs - - >>> import seaborn as sns; sns.set_theme() - >>> sns.palplot(sns.light_palette("purple")) - - Generate a palette that increases in lightness: - - .. plot:: - :context: close-figs - - >>> sns.palplot(sns.light_palette("seagreen", reverse=True)) - - Generate a palette from an HUSL-space seed: - - .. plot:: - :context: close-figs - - >>> sns.palplot(sns.light_palette((260, 75, 60), input="husl")) - - Generate a colormap object: - - .. plot:: - :context: close-figs - - >>> from numpy import arange - >>> x = arange(25).reshape(5, 5) - >>> cmap = sns.light_palette("#2ecc71", as_cmap=True) - >>> ax = sns.heatmap(x, cmap=cmap) + .. include:: ../docstrings/light_palette.rst """ rgb = _color_to_rgb(color, input) @@ -652,11 +551,12 @@ def diverging_palette(h_neg, h_pos, s=75, l=50, sep=1, n=6, # noqa center : {"light", "dark"}, optional Whether the center of the palette is light or dark as_cmap : bool, optional - If True, return a :class:`matplotlib.colors.Colormap`. + If True, return a :class:`matplotlib.colors.ListedColormap`. Returns ------- - list of RGB tuples or :class:`matplotlib.colors.Colormap` + palette + list of RGB tuples or :class:`matplotlib.colors.ListedColormap` See Also -------- @@ -665,39 +565,7 @@ def diverging_palette(h_neg, h_pos, s=75, l=50, sep=1, n=6, # noqa Examples -------- - - Generate a blue-white-red palette: - - .. plot:: - :context: close-figs - - >>> import seaborn as sns; sns.set_theme() - >>> sns.palplot(sns.diverging_palette(240, 10, n=9)) - - Generate a brighter green-white-purple palette: - - .. plot:: - :context: close-figs - - >>> sns.palplot(sns.diverging_palette(150, 275, s=80, l=55, n=9)) - - Generate a blue-black-red palette: - - .. plot:: - :context: close-figs - - >>> sns.palplot(sns.diverging_palette(250, 15, s=75, l=40, - ... n=9, center="dark")) - - Generate a colormap object: - - .. plot:: - :context: close-figs - - >>> from numpy import arange - >>> x = arange(25).reshape(5, 5) - >>> cmap = sns.diverging_palette(220, 20, as_cmap=True) - >>> ax = sns.heatmap(x, cmap=cmap) + .. include: ../docstrings/diverging_palette.rst """ palfunc = dict(dark=dark_palette, light=light_palette)[center] @@ -715,16 +583,21 @@ def blend_palette(colors, n_colors=6, as_cmap=False, input="rgb"): Parameters ---------- - colors : sequence of colors in various formats interpreted by ``input`` - hex code, html color name, or tuple in ``input`` space. + colors : sequence of colors in various formats interpreted by `input` + hex code, html color name, or tuple in `input` space. n_colors : int, optional Number of colors in the palette. as_cmap : bool, optional - If True, return a :class:`matplotlib.colors.Colormap`. + If True, return a :class:`matplotlib.colors.ListedColormap`. Returns ------- - list of RGB tuples or :class:`matplotlib.colors.Colormap` + palette + list of RGB tuples or :class:`matplotlib.colors.ListedColormap` + + Examples + -------- + .. include: ../docstrings/blend_palette.rst """ colors = [_color_to_rgb(color, input) for color in colors] @@ -741,18 +614,17 @@ def xkcd_palette(colors): See xkcd for the full list of colors: https://xkcd.com/color/rgb/ - This is just a simple wrapper around the ``seaborn.xkcd_rgb`` dictionary. + This is just a simple wrapper around the `seaborn.xkcd_rgb` dictionary. Parameters ---------- colors : list of strings - List of keys in the ``seaborn.xkcd_rgb`` dictionary. + List of keys in the `seaborn.xkcd_rgb` dictionary. Returns ------- - palette : seaborn color palette - Returns the list of colors as RGB tuples in an object that behaves like - other seaborn color palettes. + palette + A list of colors as RGB tuples. See Also -------- @@ -769,18 +641,17 @@ def crayon_palette(colors): Colors are taken from here: https://en.wikipedia.org/wiki/List_of_Crayola_crayon_colors - This is just a simple wrapper around the ``seaborn.crayons`` dictionary. + This is just a simple wrapper around the `seaborn.crayons` dictionary. Parameters ---------- colors : list of strings - List of keys in the ``seaborn.crayons`` dictionary. + List of keys in the `seaborn.crayons` dictionary. Returns ------- - palette : seaborn color palette - Returns the list of colors as rgb tuples in an object that behaves like - other seaborn color palettes. + palette + A list of colors as RGB tuples. See Also -------- @@ -803,20 +674,19 @@ def cubehelix_palette(n_colors=6, start=0, rot=.4, gamma=1.0, hue=0.8, defaults. In addition to using this function, it is also possible to generate a - cubehelix palette generally in seaborn using a string-shorthand; see the - example below. + cubehelix palette generally in seaborn using a string starting with + `ch:` and containing other parameters (e.g. `"ch:s=.25,r=-.5"`). Parameters ---------- n_colors : int Number of colors in the palette. start : float, 0 <= start <= 3 - The hue at the start of the helix. + The hue value at the start of the helix. rot : float Rotations around the hue wheel over the range of the palette. gamma : float 0 <= gamma - Gamma factor to emphasize darker (gamma < 1) or lighter (gamma > 1) - colors. + Nonlinearity to emphasize dark (gamma < 1) or light (gamma > 1) colors. hue : float, 0 <= hue <= 1 Saturation of the colors. dark : float 0 <= dark <= 1 @@ -826,11 +696,12 @@ def cubehelix_palette(n_colors=6, start=0, rot=.4, gamma=1.0, hue=0.8, reverse : bool If True, the palette will go from dark to light. as_cmap : bool - If True, return a :class:`matplotlib.colors.Colormap`. + If True, return a :class:`matplotlib.colors.ListedColormap`. Returns ------- - list of RGB tuples or :class:`matplotlib.colors.Colormap` + palette + list of RGB tuples or :class:`matplotlib.colors.ListedColormap` See Also -------- @@ -847,60 +718,7 @@ def cubehelix_palette(n_colors=6, start=0, rot=.4, gamma=1.0, hue=0.8, Examples -------- - - Generate the default palette: - - .. plot:: - :context: close-figs - - >>> import seaborn as sns; sns.set_theme() - >>> sns.palplot(sns.cubehelix_palette()) - - Rotate backwards from the same starting location: - - .. plot:: - :context: close-figs - - >>> sns.palplot(sns.cubehelix_palette(rot=-.4)) - - Use a different starting point and shorter rotation: - - .. plot:: - :context: close-figs - - >>> sns.palplot(sns.cubehelix_palette(start=2.8, rot=.1)) - - Reverse the direction of the lightness ramp: - - .. plot:: - :context: close-figs - - >>> sns.palplot(sns.cubehelix_palette(reverse=True)) - - Generate a colormap object: - - .. plot:: - :context: close-figs - - >>> from numpy import arange - >>> x = arange(25).reshape(5, 5) - >>> cmap = sns.cubehelix_palette(as_cmap=True) - >>> ax = sns.heatmap(x, cmap=cmap) - - Use the full lightness range: - - .. plot:: - :context: close-figs - - >>> cmap = sns.cubehelix_palette(dark=0, light=1, as_cmap=True) - >>> ax = sns.heatmap(x, cmap=cmap) - - Use through the :func:`color_palette` interface: - - .. plot:: - :context: close-figs - - >>> sns.palplot(sns.color_palette("ch:2,r=.2,l=.6")) + .. include:: ../docstrings/cubehelix_palette.rst """ def get_color_function(p0, p1): @@ -996,32 +814,17 @@ def set_color_codes(palette="deep"): set_palette : Color codes can also be set through the function that sets the matplotlib color cycle. - Examples - -------- - - Map matplotlib color codes to the default seaborn palette. - - .. plot:: - :context: close-figs - - >>> import matplotlib.pyplot as plt - >>> import seaborn as sns; sns.set_theme() - >>> sns.set_color_codes() - >>> _ = plt.plot([0, 1], color="r") - - Use a different seaborn palette. - - .. plot:: - :context: close-figs - - >>> sns.set_color_codes("dark") - >>> _ = plt.plot([0, 1], color="g") - >>> _ = plt.plot([0, 2], color="m") - """ if palette == "reset": - colors = [(0., 0., 1.), (0., .5, 0.), (1., 0., 0.), (.75, 0., .75), - (.75, .75, 0.), (0., .75, .75), (0., 0., 0.)] + colors = [ + (0., 0., 1.), + (0., .5, 0.), + (1., 0., 0.), + (.75, 0., .75), + (.75, .75, 0.), + (0., .75, .75), + (0., 0., 0.) + ] elif not isinstance(palette, str): err = "set_color_codes requires a named seaborn palette" raise TypeError(err) diff --git a/seaborn/rcmod.py b/seaborn/rcmod.py index 145698ca69..ca70a44695 100644 --- a/seaborn/rcmod.py +++ b/seaborn/rcmod.py @@ -516,12 +516,6 @@ def set_palette(palette, n_colors=None, desat=None, color_codes=False): If ``True`` and ``palette`` is a seaborn palette, remap the shorthand color codes (e.g. "b", "g", "r", etc.) to the colors from this palette. - Examples - -------- - >>> set_palette("Reds") - - >>> set_palette("Set1", 8, .75) - See Also -------- color_palette : build a color palette or set the color cycle temporarily diff --git a/seaborn/widgets.py b/seaborn/widgets.py index c75cc66c48..502812af57 100644 --- a/seaborn/widgets.py +++ b/seaborn/widgets.py @@ -2,26 +2,12 @@ import matplotlib.pyplot as plt from matplotlib.colors import LinearSegmentedColormap -# Lots of different places that widgets could come from... try: from ipywidgets import interact, FloatSlider, IntSlider except ImportError: - import warnings - # ignore ShimWarning raised by IPython, see GH #892 - with warnings.catch_warnings(): - warnings.simplefilter("ignore") - try: - from IPython.html.widgets import interact, FloatSlider, IntSlider - except ImportError: - try: - from IPython.html.widgets import (interact, - FloatSliderWidget, - IntSliderWidget) - FloatSlider = FloatSliderWidget - IntSlider = IntSliderWidget - except ImportError: - pass - + def interact(f): + msg = "Interactive palettes require `ipywidgets`, which is not installed." + raise ImportError(msg) from .miscplot import palplot from .palettes import (color_palette, dark_palette, light_palette, diff --git a/tests/test_palettes.py b/tests/test_palettes.py index cda371c089..4d9e9f916e 100644 --- a/tests/test_palettes.py +++ b/tests/test_palettes.py @@ -416,9 +416,24 @@ def test_preserved_palette_length(self): pal_out = palettes.color_palette(pal_in) assert pal_in == pal_out - def test_html_rep(self): + def test_html_repr(self): pal = palettes.color_palette() html = pal._repr_html_() for color in pal.as_hex(): assert color in html + + def test_colormap_display_patch(self): + + orig_repr_png = getattr(mpl.colors.Colormap, "_repr_png_", None) + orig_repr_html = getattr(mpl.colors.Colormap, "_repr_html_", None) + + try: + palettes._patch_colormap_display() + cmap = mpl.cm.Reds + assert cmap._repr_html_().startswith('