{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2605c8d0-5872-4dff-9172-db81fac1cee1",
   "metadata": {
    "tags": [
     "hide"
    ]
   },
   "outputs": [],
   "source": [
    "import seaborn.objects as so\n",
    "from seaborn import load_dataset\n",
    "penguins = load_dataset(\"penguins\")\n",
    "diamonds = load_dataset(\"diamonds\")"
   ]
  },
  {
   "cell_type": "raw",
   "id": "e70d701a-cd7c-4b38-aaa0-4729e2be56d9",
   "metadata": {},
   "source": [
    "Use this transform to layer multiple marks that would otherwise overlap and be hard to interpret:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5ea7a2c4-cb69-4ad0-8ea8-73067b756371",
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    so.Plot(penguins, \"species\", \"body_mass_g\")\n",
    "    .add(so.Dots(), so.Jitter())\n",
    "    .add(so.Range(), so.Perc([25, 75]), so.Shift(x=.2))\n",
    ")"
   ]
  },
  {
   "cell_type": "raw",
   "id": "940b87b2-04fb-40ba-a62f-52f461039ab9",
   "metadata": {},
   "source": [
    "For y variables with a nominal scale, bear in mind that the axis will be inverted and a positive shift will move downwards:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "54b5f728-4fbc-474a-8865-0f58d0ad9b0b",
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    so.Plot(diamonds, \"carat\", \"clarity\")\n",
    "    .add(so.Dots(), so.Jitter())\n",
    "    .add(so.Range(), so.Perc([25, 75]), so.Shift(y=.25))\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "78d9bb6a-ea3d-491e-b43e-25efd386bd59",
   "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
}
