{
 "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",
    "mpg = load_dataset(\"mpg\")"
   ]
  },
  {
   "cell_type": "raw",
   "id": "f8e7b343-0301-49b3-8d42-862266d322bb",
   "metadata": {},
   "source": [
    "This mark draws relatively small, partially-transparent dots:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d668d7f6-555b-4b5d-876e-35e259076d2a",
   "metadata": {},
   "outputs": [],
   "source": [
    "p1 = so.Plot(mpg, \"horsepower\", \"mpg\")\n",
    "p1.add(so.Dots())"
   ]
  },
  {
   "cell_type": "raw",
   "id": "a2cf4669-9c91-4adc-9e3a-3b0660e7898e",
   "metadata": {},
   "source": [
    "Fixing or mapping the `color` property changes both the stroke (edge) and fill:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bba2b1c5-22fd-4f44-af8d-defb31dfbe9d",
   "metadata": {},
   "outputs": [],
   "source": [
    "p1.add(so.Dots(), color=\"origin\")"
   ]
  },
  {
   "cell_type": "raw",
   "id": "bf967d57-22cf-4bce-b718-aae6936719e6",
   "metadata": {},
   "source": [
    "These properties can be independently parametrized (although the resulting plot may not always be clear):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c45261a9-fb88-4eb5-b633-060debda261b",
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    p1.add(so.Dots(fillalpha=.5), color=\"origin\", fillcolor=\"weight\")\n",
    "    .scale(fillcolor=\"binary\")\n",
    ")"
   ]
  },
  {
   "cell_type": "raw",
   "id": "b20dcaee-8e09-4a76-8eff-5289ef43ea8c",
   "metadata": {},
   "source": [
    "Filled and unfilled markers will happily mix:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a1a9bdda-abb7-4850-a936-ceed518b9b17",
   "metadata": {},
   "outputs": [],
   "source": [
    "p1.add(so.Dots(stroke=1), marker=\"origin\").scale(marker=[\"o\", \"x\", (6, 2, 1)])"
   ]
  },
  {
   "cell_type": "raw",
   "id": "1d932f10-e8f8-4114-9362-3da82c7b5ac0",
   "metadata": {},
   "source": [
    "The partial opacity also helps to see local density when using jitter:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "692e1611-4804-4979-b616-041e9fa9cdd9",
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    so.Plot(mpg, \"horsepower\", \"origin\")\n",
    "    .add(so.Dots(), so.Jitter(.25))\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "acd5788f-e62b-497c-a109-f0bc02b8cae9",
   "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
}
