{
 "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",
    "penguins = load_dataset(\"penguins\")"
   ]
  },
  {
   "cell_type": "raw",
   "id": "3a874676-6b0d-45b1-a227-857a536c5ed2",
   "metadata": {},
   "source": [
    "By default, faceted plots will share all axes:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "615d0765-98c7-4694-8115-a6d1b3557fe7",
   "metadata": {},
   "outputs": [],
   "source": [
    "p = (\n",
    "    so.Plot(penguins, x=\"bill_length_mm\", y=\"bill_depth_mm\")\n",
    "    .facet(col=\"species\", row=\"sex\")\n",
    "    .add(so.Dots())\n",
    ")\n",
    "p"
   ]
  },
  {
   "cell_type": "raw",
   "id": "8b75feb1-491e-4031-9fcb-619037bd1bfb",
   "metadata": {},
   "source": [
    "Set a coordinate variable to `False` to let each subplot adapt independently:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4c23c570-ca9b-49cc-9aab-7d167218454b",
   "metadata": {},
   "outputs": [],
   "source": [
    "p.share(x=False, y=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cc46d8d0-7ab9-44c2-8a28-c656fe86c085",
   "metadata": {},
   "source": [
    "It's also possible to share only across rows or columns:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7cb8136b-9aa3-4c48-bd41-fc0e19fa997c",
   "metadata": {},
   "outputs": [],
   "source": [
    "p.share(x=\"col\", y=\"row\")"
   ]
  },
  {
   "cell_type": "raw",
   "id": "91533aba-45ae-4011-b72c-10f5f79e01d0",
   "metadata": {},
   "source": [
    "This method is also relevant for paired plots, which have different defaults. In this case, you would need to opt *in* to full sharing (although it may not always make sense):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e2b71770-e520-45b9-b41c-a66431f21e1f",
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    so.Plot(penguins, y=\"flipper_length_mm\")\n",
    "    .pair(x=[\"bill_length_mm\", \"bill_depth_mm\"])\n",
    "    .add(so.Dots())\n",
    "    .share(x=True)\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "92c29080-8561-4c90-8581-4d435a5f96b9",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "py310",
   "language": "python",
   "name": "py310"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
