{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9252d5a5-8af1-4f99-b799-ee044329fb23",
   "metadata": {
    "tags": [
     "hide"
    ]
   },
   "outputs": [],
   "source": [
    "import seaborn.objects as so\n",
    "from seaborn import load_dataset\n",
    "anscombe = load_dataset(\"anscombe\")"
   ]
  },
  {
   "cell_type": "raw",
   "id": "406f6608-daf2-4d3e-9f2c-1a9e93ecb840",
   "metadata": {},
   "source": [
    "The default theme uses the same parameters as :func:`seaborn.set_theme` with no additional arguments:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5e3d639c-1167-48d2-b9b5-c26b7fa12c66",
   "metadata": {},
   "outputs": [],
   "source": [
    "p = (\n",
    "    so.Plot(anscombe, \"x\", \"y\", color=\"dataset\")\n",
    "    .facet(\"dataset\", wrap=2)\n",
    "    .add(so.Line(), so.PolyFit(order=1))\n",
    "    .add(so.Dot())\n",
    ")\n",
    "p"
   ]
  },
  {
   "cell_type": "raw",
   "id": "e2823a91-47f1-40a8-a150-32f00bcb59ea",
   "metadata": {},
   "source": [
    "Pass a dictionary of rc parameters to change the appearance of the plot:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "368c8cdb-2e6f-4520-8412-cd1864a6c09b",
   "metadata": {},
   "outputs": [],
   "source": [
    "p.theme({\"axes.facecolor\": \"w\", \"axes.edgecolor\": \"slategray\"})"
   ]
  },
  {
   "cell_type": "raw",
   "id": "637cf0ba-e9b7-4f0f-a628-854e300c4122",
   "metadata": {},
   "source": [
    "Many (though not all) mark properties will reflect theme parameters by default:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9eb330b3-f424-405b-9653-5df9948792d9",
   "metadata": {},
   "outputs": [],
   "source": [
    "p.theme({\"lines.linewidth\": 4})"
   ]
  },
  {
   "cell_type": "raw",
   "id": "0186e852-9c47-4da1-999a-f61f41687dfb",
   "metadata": {},
   "source": [
    "Apply seaborn styles by passing in the output of the style functions:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "48cafbb1-37da-42c7-a20e-b63c0fef4d41",
   "metadata": {},
   "outputs": [],
   "source": [
    "from seaborn import axes_style\n",
    "p.theme(axes_style(\"ticks\"))"
   ]
  },
  {
   "cell_type": "raw",
   "id": "bbdecb4b-382a-49f3-8928-16f5f72c39b5",
   "metadata": {},
   "source": [
    "Or apply styles that ship with matplotlib:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "84a7ac28-798d-4560-bbc8-d214fd6fcada",
   "metadata": {},
   "outputs": [],
   "source": [
    "from matplotlib import style\n",
    "p.theme(style.library[\"fivethirtyeight\"])"
   ]
  },
  {
   "cell_type": "raw",
   "id": "e1870ad0-48a0-4fd1-a557-d337979bc845",
   "metadata": {},
   "source": [
    "Multiple parameter dictionaries should be passed to the same function call. On Python 3.9+, you can use dictionary union syntax for this:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dec4db5b-1b2b-4b9d-97e1-9cf0f20d6b83",
   "metadata": {},
   "outputs": [],
   "source": [
    "from seaborn import plotting_context\n",
    "p.theme(axes_style(\"whitegrid\") | plotting_context(\"talk\"))"
   ]
  },
  {
   "cell_type": "raw",
   "id": "7cc09720-887d-463e-a162-1e3ef8a46ad9",
   "metadata": {},
   "source": [
    "The default theme for all :class:`Plot` instances can be changed using the :attr:`Plot.config` attribute:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4e535ddf-d394-4ce1-8d09-4dc95ca314b4",
   "metadata": {},
   "outputs": [],
   "source": [
    "so.Plot.config.theme.update(axes_style(\"white\"))\n",
    "p"
   ]
  },
  {
   "cell_type": "raw",
   "id": "2f19f645-3f8d-4044-82e9-4a87165a0078",
   "metadata": {},
   "source": [
    "See :ref:`Plot Configuration <plot_config>` for more details."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "py310",
   "language": "python",
   "name": "py310"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
