{
 "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",
    "healthexp = (\n",
    "    load_dataset(\"healthexp\")\n",
    "    .pivot(index=\"Year\", columns=\"Country\", values=\"Spending_USD\")\n",
    "    .interpolate()\n",
    "    .stack()\n",
    "    .rename(\"Spending_USD\")\n",
    "    .reset_index()\n",
    "    .sort_values(\"Country\")\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6d3bc7fe-0b0b-49eb-8f8b-ddd8c7441044",
   "metadata": {},
   "outputs": [],
   "source": [
    "p = so.Plot(healthexp, \"Year\", \"Spending_USD\").facet(\"Country\", wrap=3)\n",
    "p.add(so.Area())"
   ]
  },
  {
   "cell_type": "raw",
   "id": "3a47b7f1-31ef-4218-a1ea-c289f3c64ab5",
   "metadata": {},
   "source": [
    "The `color` property sets both the edge and fill color:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1697359a-bf26-49d0-891b-49c207cab82d",
   "metadata": {},
   "outputs": [],
   "source": [
    "p.add(so.Area(), color=\"Country\")"
   ]
  },
  {
   "cell_type": "raw",
   "id": "9bfaed37-7153-45d9-89e5-b348c7c14401",
   "metadata": {},
   "source": [
    "It's also possible to map only the `edgecolor`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "39e5c9e5-793e-450c-a5d2-e09d5ad1f854",
   "metadata": {},
   "outputs": [],
   "source": [
    "p.add(so.Area(color=\".5\", edgewidth=2), edgecolor=\"Country\")"
   ]
  },
  {
   "cell_type": "raw",
   "id": "0b1a5297-9e96-472d-b284-919048e41358",
   "metadata": {},
   "source": [
    "The mark is drawn as a polygon, but it can be combined with :class:`Line` to draw a shaded region by setting `edgewidth=0`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "42b65535-acf6-4634-84bd-6e35305e3018",
   "metadata": {},
   "outputs": [],
   "source": [
    "p.add(so.Area(edgewidth=0)).add(so.Line())"
   ]
  },
  {
   "cell_type": "raw",
   "id": "59761f97-eadb-4047-9e6b-09339545fe57",
   "metadata": {},
   "source": [
    "The layer's orientation defines the axis that the mark fills from:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a1c30f88-6287-486d-ae4b-fc272bc8e6ab",
   "metadata": {},
   "outputs": [],
   "source": [
    "p.add(so.Area(), x=\"Spending_USD\", y=\"Year\", orient=\"y\")"
   ]
  },
  {
   "cell_type": "raw",
   "id": "f1b893c5-6847-4e5b-9fc2-4190ddd75099",
   "metadata": {},
   "source": [
    "This mark can be stacked to show part-whole relationships:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "66a79e6e-3e7f-4f54-9394-f8b003a0e228",
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    so.Plot(healthexp, \"Year\", \"Spending_USD\", color=\"Country\")\n",
    "    .add(so.Area(alpha=.7), so.Stack())\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "69f4e423-94f4-4003-b337-12162d1040c2",
   "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
}
