{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2923956c-f141-4ecb-ab08-e819099f0fa9",
   "metadata": {
    "tags": [
     "hide"
    ]
   },
   "outputs": [],
   "source": [
    "import seaborn.objects as so\n",
    "from seaborn import load_dataset\n",
    "tips = load_dataset(\"tips\")\n",
    "glue = load_dataset(\"glue\")"
   ]
  },
  {
   "cell_type": "raw",
   "id": "f8e7b343-0301-49b3-8d42-862266d322bb",
   "metadata": {},
   "source": [
    "This mark draws relatively large, filled dots by default:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f92e97d0-b6a5-41ec-8507-dc64e60cb6e0",
   "metadata": {},
   "outputs": [],
   "source": [
    "p1 = so.Plot(tips, \"total_bill\", \"tip\")\n",
    "p1.add(so.Dot())"
   ]
  },
  {
   "cell_type": "raw",
   "id": "625abe2a-7b0b-42a7-bfbc-dc2bfaf14897",
   "metadata": {},
   "source": [
    "While :class:`Dots` is a better choice for dense scatter plots, adding a thin edge can help to resolve individual points:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a3c7c22d-c7ce-40a9-941b-a8bc30db1e54",
   "metadata": {},
   "outputs": [],
   "source": [
    "p1.add(so.Dot(edgecolor=\"w\"))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "398a43e1-4d45-42ea-bc87-41a8602540a4",
   "metadata": {},
   "source": [
    "Dodging and jittering can also help to reduce overplotting, when appropriate:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1b15e393-35cf-457f-8180-d92d05e2675a",
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    so.Plot(tips, \"total_bill\", \"day\", color=\"sex\")\n",
    "    .add(so.Dot(), so.Dodge(), so.Jitter(.2))\n",
    ")"
   ]
  },
  {
   "cell_type": "raw",
   "id": "12453ada-40e6-4aad-9f32-ba41fd7b27ca",
   "metadata": {},
   "source": [
    "The larger dot size makes this mark well suited to representing values along a nominal scale:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bd2edac0-ee6b-4cc9-8201-641b589630b8",
   "metadata": {},
   "outputs": [],
   "source": [
    "p2 = so.Plot(glue, \"Score\", \"Model\").facet(\"Task\", wrap=4).limit(x=(-5, 105))\n",
    "p2.add(so.Dot())"
   ]
  },
  {
   "cell_type": "raw",
   "id": "ddd86209-d5cd-4f7a-9274-c578bc6a9f07",
   "metadata": {},
   "source": [
    "A number of properties can be set or mapped:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d00cdc35-4b9c-4f32-a047-8e036e565c4f",
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    p2\n",
    "    .add(so.Dot(pointsize=6), color=\"Year\", marker=\"Encoder\")\n",
    "    .scale(marker=[\"o\", \"s\"], color=\"flare\")\n",
    ")"
   ]
  },
  {
   "cell_type": "raw",
   "id": "061e22f4-8505-425d-8c80-8ac82c6a3125",
   "metadata": {},
   "source": [
    "Note that the edge properties are parameterized differently for filled and unfilled markers; use `stroke` and `color` rather than `edgewidth` and `edgecolor` if the marker is unfilled:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "964b00be-1c29-4664-838d-0daeead9154a",
   "metadata": {},
   "outputs": [],
   "source": [
    "p2.add(so.Dot(stroke=1.5), fill=\"Encoder\", color=\"Encoder\")"
   ]
  },
  {
   "cell_type": "raw",
   "id": "fb5e1383-1460-4389-a67b-09ec7965af90",
   "metadata": {},
   "source": [
    "Combine with :class:`Range` to show error bars:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b2618c22-bc7f-4ddd-9824-346e8d9b2b51",
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    so.Plot(tips, x=\"total_bill\", y=\"day\")\n",
    "    .add(so.Dot(pointsize=3), so.Shift(y=.2), so.Jitter(.2))\n",
    "    .add(so.Dot(), so.Agg())\n",
    "    .add(so.Range(), so.Est(errorbar=(\"se\", 2)))\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e5dc04fd-dba4-4b86-99a1-31ba00c7650d",
   "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
}
