{
 "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",
    "fmri = load_dataset(\"fmri\").query(\"region == 'parietal'\")\n",
    "seaice = (\n",
    "    load_dataset(\"seaice\")\n",
    "    .assign(\n",
    "        Day=lambda x: x[\"Date\"].dt.day_of_year,\n",
    "        Year=lambda x: x[\"Date\"].dt.year,\n",
    "    )\n",
    "    .query(\"Year >= 1980\")\n",
    "    .astype({\"Year\": str})\n",
    "    .pivot(index=\"Day\", columns=\"Year\", values=\"Extent\")\n",
    "    .filter([\"1980\", \"2019\"])\n",
    "    .dropna()\n",
    "    .reset_index()\n",
    ")"
   ]
  },
  {
   "cell_type": "raw",
   "id": "e840e876-fbd6-4bfd-868c-a9d7af7913fa",
   "metadata": {},
   "source": [
    "The mark fills between pairs of data points to show an interval on the value axis:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "518cf20d-bb0b-433a-9b25-f1ed8d432149",
   "metadata": {},
   "outputs": [],
   "source": [
    "p = so.Plot(seaice, x=\"Day\", ymin=\"1980\", ymax=\"2019\")\n",
    "p.add(so.Band())"
   ]
  },
  {
   "cell_type": "raw",
   "id": "fa50b778-13f9-4368-a967-68365fd51117",
   "metadata": {},
   "source": [
    "By default it draws a faint ribbon with no edges, but edges can be added:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a05176c4-0615-49ca-a2df-48ced8b5a8a8",
   "metadata": {},
   "outputs": [],
   "source": [
    "p.add(so.Band(alpha=.5, edgewidth=2))"
   ]
  },
  {
   "cell_type": "raw",
   "id": "776d192a-f35f-4253-be7f-01e4b2466dad",
   "metadata": {},
   "source": [
    "The defaults are optimized for the main expected usecase, where the mark is combined with a line to show an errorbar interval:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "69f4e423-94f4-4003-b337-12162d1040c2",
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    so.Plot(fmri, x=\"timepoint\", y=\"signal\", color=\"event\")\n",
    "    .add(so.Band(), so.Est())\n",
    "    .add(so.Line(), so.Agg())\n",
    ")"
   ]
  },
  {
   "cell_type": "raw",
   "id": "9f0c82bf-3457-4ac5-ba48-8930bac03d75",
   "metadata": {},
   "source": [
    "When min/max values are not explicitly assigned or added in a transform, the band will cover the full extent of the data:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "309f578e-da3d-4dc5-b6ac-a354321334c8",
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    so.Plot(fmri, x=\"timepoint\", y=\"signal\", color=\"event\")\n",
    "    .add(so.Line(linewidth=.5), group=\"subject\")\n",
    "    .add(so.Band())\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4330a3cd-63fe-470a-8e83-09e9606643b5",
   "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
}
