{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a38a6fed-51de-4dbc-8d5b-4971d06acf2e",
   "metadata": {
    "tags": [
     "hide"
    ]
   },
   "outputs": [],
   "source": [
    "import seaborn.objects as so"
   ]
  },
  {
   "cell_type": "raw",
   "id": "38081259-9382-4623-8d67-09aa114e0949",
   "metadata": {},
   "source": [
    "Theme configuration\n",
    "^^^^^^^^^^^^^^^^^^^\n",
    "\n",
    "Theme changes made through the the :attr:`Plot.config` interface will apply to all subsequent :class:`Plot` instances. Use the :meth:`Plot.theme` method to modify the theme on a plot-by-plot basis.\n",
    "\n",
    "The theme is a dictionary of matplotlib `rc parameters <https://matplotlib.org/stable/tutorials/introductory/customizing.html>`_. You can set individual parameters directly:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "34ca0ce9-5284-47b6-8281-180709dbec89",
   "metadata": {},
   "outputs": [],
   "source": [
    "so.Plot.config.theme[\"axes.facecolor\"] = \"white\""
   ]
  },
  {
   "cell_type": "raw",
   "id": "b3f93646-8370-4c16-ace4-7bb811688758",
   "metadata": {},
   "source": [
    "To change the overall style of the plot, update the theme with a dictionary of parameters, perhaps from one of seaborn's theming functions:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8e5eb7d3-cc7a-4231-b887-db37045f3db4",
   "metadata": {},
   "outputs": [],
   "source": [
    "from seaborn import axes_style\n",
    "so.Plot.config.theme.update(axes_style(\"whitegrid\"))"
   ]
  },
  {
   "cell_type": "raw",
   "id": "f7c7bd9c-722d-45db-902a-c2dcdef571ee",
   "metadata": {},
   "source": [
    "To sync :class:`Plot` with matplotlib's global state, pass the `rcParams` dictionary:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fd1cd96e-1a2c-474a-809f-20b8c4794578",
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib as mpl\n",
    "so.Plot.config.theme.update(mpl.rcParams)"
   ]
  },
  {
   "cell_type": "raw",
   "id": "7e305ec1-4a83-411f-91df-aee2ec4d1806",
   "metadata": {},
   "source": [
    "The theme can also be reset back to seaborn defaults:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e3146b1d-1b5e-464f-a631-e6d6caf161b3",
   "metadata": {},
   "outputs": [],
   "source": [
    "so.Plot.config.theme.reset()"
   ]
  },
  {
   "cell_type": "raw",
   "id": "b6370088-02f6-4933-91c0-5763b86b7299",
   "metadata": {},
   "source": [
    "Display configuration\n",
    "^^^^^^^^^^^^^^^^^^^^^\n",
    "\n",
    "When returned from the last statement in a notebook cell, a :class:`Plot` will be compiled and embedded in the notebook as an image. By default, the image is rendered as HiDPI PNG. Alternatively, it is possible to display the plots in SVG format:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1bd9966e-d08f-46b4-ad44-07276d5efba8",
   "metadata": {},
   "outputs": [],
   "source": [
    "so.Plot.config.display[\"format\"] = \"svg\""
   ]
  },
  {
   "cell_type": "raw",
   "id": "845239ed-3a0f-4a94-97d0-364c2db3b9c8",
   "metadata": {},
   "source": [
    "SVG images use vector graphics with \"infinite\" resolution, so they will appear crisp at any amount of zoom. The downside is that each plot element is drawn separately, so the image data can get very heavy for certain kinds of plots (e.g., for dense scatterplots).\n",
    "\n",
    "The HiDPI scaling of the default PNG images will also inflate the size of the notebook they are stored in. (Unlike with SVG, PNG size will scale with the dimensions of the plot but not its complexity). When not useful, it can be disabled:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "13ac09f7-d4ad-4b4e-8963-edc0c6c71a94",
   "metadata": {},
   "outputs": [],
   "source": [
    "so.Plot.config.display[\"hidpi\"] = False"
   ]
  },
  {
   "cell_type": "raw",
   "id": "ddebe3eb-1d64-41e9-9cfd-f8359d6f8a38",
   "metadata": {},
   "source": [
    "The embedded images are scaled down slightly — independently from the figure size or DPI — so that more information can be presented on the screen. The precise scaling factor is also configurable:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f10c5596-598d-4258-bf8f-67c07eaba266",
   "metadata": {},
   "outputs": [],
   "source": [
    "so.Plot.config.display[\"scaling\"] = 0.7"
   ]
  }
 ],
 "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
}
