{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "2d236e81",
   "metadata": {},
   "source": [
    "# Seaborn Crash Course\n",
    "Going to be somewhat documenting the process of learning and using Seaborn within the Data Mining project.\n",
    "\n",
    "Even better of an idea is to check out the docs here:\n",
    "- https://seaborn.pydata.org/tutorial.html\n",
    "\n",
    "***This is where the fun begins***\n",
    "\n",
    "Usually how it goes is:\n",
    "1. Importing Seaborn\n",
    "2. Loading a dataset into a variable\n",
    "3. Plotting whatever you'd like (Need to explicitly mention the variables to avoid misinterpretation, like R :D)\n",
    "\n",
    "Below is a simple *Scatter plot* with histograms and splines."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "94ecb2cf",
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.FacetGrid at 0x29e084feee0>"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 24872 characters]",
      "text/plain": [
       "<Figure size 600x600 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 62904 characters]",
      "text/plain": [
       "<Figure size 1072.12x500 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import seaborn as sns\n",
    "\n",
    "# Loading a dataset that comes with Seaborn\n",
    "tips_dat = sns.load_dataset(\"tips\")\n",
    "\n",
    "tip_plot = sns.JointGrid(x = \"total_bill\", y = \"tip\", data = tips_dat);\n",
    "tip_plot.plot_joint(sns.histplot)\n",
    "tip_plot.plot_marginals(sns.kdeplot)\n",
    "\n",
    "sns.relplot(\n",
    "    data=tips_dat,\n",
    "    x=\"total_bill\", y=\"tip\", hue=\"smoker\", col=\"time\",\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "d58e10cb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.FacetGrid at 0x29e79167c70>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 95560 characters]",
      "text/plain": [
       "<Figure size 578.875x500 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 109796 characters]",
      "text/plain": [
       "<Figure size 585.5x500 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "flights_dat = sns.load_dataset(\"flights\")\n",
    "\n",
    "sns.relplot(data=flights_dat, x=\"year\", y=\"passengers\", hue=\"month\", kind=\"line\")\n",
    "sns.relplot(data=flights_dat, x=\"month\", y=\"passengers\", hue=\"year\", kind=\"line\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "47f6eb51",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.FacetGrid at 0x29e0019e8e0>"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 54988 characters]",
      "text/plain": [
       "<Figure size 800x800 with 4 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "anscombe_dat = sns.load_dataset(\"anscombe\")\n",
    "\n",
    "sns.lmplot(\n",
    "    data = anscombe_dat, x = \"x\", y = \"y\", col = \"dataset\", hue = \"dataset\",\n",
    "    col_wrap = 2, palette = \"muted\", ci = None,\n",
    "    height = 4, scatter_kws = {\"s\": 50, \"alpha\": 1}\n",
    ")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "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.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
