{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "7Y9AAfUVODyA"
   },
   "source": [
    "# Lab 3\n",
    "Please fill in the cells following the instructions below."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "ih3yNmMbOND_"
   },
   "source": [
    "## Part I\n",
    "\n",
    "Read [Matplotlib's Quick Start Guide](https://matplotlib.org/stable/users/explain/quick_start.html) and answer the following questions.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "UsceDC7BOb-t"
   },
   "source": [
    "1. What is the relationship between Figure and Axes objects?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "YyAAJ24bOgap"
   },
   "source": [
    "Answer goes here."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "Ld5INK0EOhB3"
   },
   "source": [
    "2. What are Artist objects?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "9TN3AoZ3Olv0"
   },
   "source": [
    "Answer goes here."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "74RHMGlKOmib"
   },
   "source": [
    "3. How do you set the color for a scatterplot, and what are three different ways you can control the marker colors? Include an example of how you could use each."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "3nL1DTmFOu0h"
   },
   "source": [
    "Answer goes here."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "SyYqDPFaOvia"
   },
   "source": [
    "4. The solid linestyle is named `solid` and can be shortened to `-`. What  are the names and shorthand for the dotted, dashed and dash-dotted linestyles?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "2g6fBnzZO5Lv"
   },
   "source": [
    "Answer goes here."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "hMlkTm7eO5-2"
   },
   "source": [
    "5. The `o` marker-style produces a circle marker. What are three other marker-styles you can specify, and what shapes do they produce?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "OwV1jsshPCnw"
   },
   "source": [
    "Answer goes here."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "8TkxMHR0PEPi"
   },
   "source": [
    "6. What functions allow you to a title, x-axis label, and y-axis label to a figure?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "LcEISJh_PMF1"
   },
   "source": [
    "Answer goes here."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "cK8KxkWuPNAn"
   },
   "source": [
    "7. What are two ways to make a plot with the y-axis on a logarithmic scale?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "UhfaotESPQU6"
   },
   "source": [
    "Answer goes here."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "H3M376LtPRSN"
   },
   "source": [
    "8. What does `subplot_mosaic` do?  \n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "4JYg0XKMPYBR"
   },
   "source": [
    "Answer goes here."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "Rfa7WL9rPY6O"
   },
   "source": [
    "## Part II\n",
    "\n",
    "Please read [An Introduction to Seaborn](https://seaborn.pydata.org/tutorial/introduction) and then complete the following tasks, referring to Seaborn's documentation as needed."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "nNedEE-RPpP_"
   },
   "source": [
    "9. Consider the following block of code producing a visual."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "yhqgQ9FqQGhZ"
   },
   "outputs": [],
   "source": [
    "import seaborn as sns\n",
    "sns.set_theme(style=\"darkgrid\")\n",
    "\n",
    "# Load an example dataset with long-form data\n",
    "fmri = sns.load_dataset(\"fmri\")\n",
    "\n",
    "# Plot the responses for different events and regions\n",
    "sns.lineplot(x=\"timepoint\", y=\"signal\",\n",
    "             hue=\"region\", style=\"event\",\n",
    "             data=fmri)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "kHPDreSZQHYa"
   },
   "source": [
    "9a. What does `sns.set_theme(style=\"darkgrid\")` do?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "H7J6FdfEQvAd"
   },
   "source": [
    "Answer goes here."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "59Ky2KmCQv7a"
   },
   "source": [
    "9b. Please explain each of the arguments provided to `lineplot`` -- what they mean and how they affect the resulting plot."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "GMPLkWTUQ4-q"
   },
   "source": [
    "Answer goes here."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "Y-vyskSsQ59P"
   },
   "source": [
    "10. Consider the following block of code producing a visual."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "oIqHuX8-RHDA"
   },
   "outputs": [],
   "source": [
    "import seaborn as sns\n",
    "sns.set_theme(style=\"whitegrid\")\n",
    "\n",
    "penguins = sns.load_dataset(\"penguins\")\n",
    "\n",
    "# Draw a nested barplot by species and sex\n",
    "g = sns.catplot(\n",
    "    data=penguins, kind=\"bar\",\n",
    "    x=\"species\", y=\"body_mass_g\", hue=\"sex\",\n",
    "    errorbar=\"sd\", palette=\"dark\", alpha=.6, height=6\n",
    ")\n",
    "g.despine(left=True)\n",
    "g.set_axis_labels(\"\", \"Body mass (g)\")\n",
    "g.legend.set_title(\"\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "n3dsw6QoRMK_"
   },
   "source": [
    "10a. Explain explain each of the arguments provided to `catplot` -- what they mean and how they affect the resulting plot."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "ovk45-qlRTS-"
   },
   "source": [
    "Answer goes here."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "VM4mfxGURVE3"
   },
   "source": [
    "10b. What does `despine` do here?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "nJev7jFDRYMr"
   },
   "source": [
    "Answer goes here."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "JNkPQI2TRZ6Z"
   },
   "source": [
    "11. Consider the following block of code producing a visual."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "6wKoxIr_Ri7E"
   },
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "sns.set_theme()\n",
    "\n",
    "# Load the example flights dataset and convert to long-form\n",
    "flights_long = sns.load_dataset(\"flights\")\n",
    "flights = (\n",
    "    flights_long\n",
    "    .pivot(index=\"month\", columns=\"year\", values=\"passengers\")\n",
    ")\n",
    "\n",
    "# Draw a heatmap with the numeric values in each cell\n",
    "f, ax = plt.subplots(figsize=(9, 6))\n",
    "sns.heatmap(flights, annot=True, fmt=\"d\", linewidths=.5, ax=ax)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "e6QEbq7SRmBG"
   },
   "source": [
    "11a. What is `flights_long.pivot` doing, and why is it done here?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "E_WwYWqiRr-3"
   },
   "source": [
    "Answer goes here."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "nwVUz3xJR1ZZ"
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "St9d8HnsRtPc"
   },
   "source": [
    "11b. Explain explain each of the arguments provided to `heatmap` -- what they mean and how they affect the resulting plot."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "MV0o1SwxR0tY"
   },
   "source": [
    "Answer goes here."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "aYzlOktgSkyy"
   },
   "source": [
    "12. Consider the following block of code producing a visual."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "uY199Bq3SlgU"
   },
   "outputs": [],
   "source": [
    "import seaborn as sns\n",
    "sns.set_theme(style=\"ticks\", palette=\"pastel\")\n",
    "\n",
    "# Load the example tips dataset\n",
    "tips = sns.load_dataset(\"tips\")\n",
    "\n",
    "# Draw a nested boxplot to show bills by day and time\n",
    "sns.boxplot(x=\"day\", y=\"total_bill\",\n",
    "            hue=\"smoker\", palette=[\"m\", \"g\"],\n",
    "            data=tips)\n",
    "sns.despine(offset=10, trim=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "FNTAbZmbSr46"
   },
   "source": [
    "12a. Explain explain each of the arguments provided to `boxplot` -- what they mean and how they affect the resulting plot."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "wprvrvSiSyNq"
   },
   "source": [
    "Answer goes here."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "g2Ig53uWSzGV"
   },
   "source": [
    "12b. What are the `offset` and `trim` arguments to `despine` doing?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "fITgtq1FS7px"
   },
   "source": [
    "Answer goes here."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "NL-hMG0ES8kT"
   },
   "source": [
    "## Part III\n",
    "\n",
    "In this part of the lab you will create a series of visuals. The data you choose to visualize is largely up to you -- feel free to use any of the datasets we have encountered so far in class, those built in to Seaborn, or others you find. There are a few constraints:\n",
    "\n",
    "1. You will need to use at least three different datasets in Part III.\n",
    "2. You will need to use matplotlib for at least one of the plots, and will need to use seaborn for at least two of them.\n",
    "\n",
    "\n",
    "Your plots should be carefully designed to tell a specific story. This does not preclude you from making rich, data-dense plots (indeed, this is encouraged!), but the effect that motivated you to make the plot should be easy to see. Your design discussion should justify the choices you made in terms of the principles we talked about in class. You need not address every principle, but any that apply to your plot should be discussed."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "bL8s_ImITmqs"
   },
   "source": [
    "13. Make a **dot plot or line plot** and describe it in the cells below. The plot should respect the principles of good visual design, and should demonstrate something interesting."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "dP9Bee8uTyNl"
   },
   "outputs": [],
   "source": [
    "# place here the code to download/load, process and visualize the data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "Xfbw52UdT27R"
   },
   "source": [
    "Place here a figure caption, explaining to the reader what the plot shows and how to interpret it."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "OPtVeGhmT9cz"
   },
   "source": [
    "Place here a description of the design decisions you made when creating the plot, and why. Which principles of good visual design were employed here?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "OmAuBB7hUwAA"
   },
   "source": [
    "14. Make a **box and whiskers plot** and describe it in the cells below. The plot should respect the principles of good visual design, and should demonstrate something interesting."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "DcThirQ4U8nP"
   },
   "outputs": [],
   "source": [
    "# place here the code to download/load, process and visualize the data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "dWEPfFmuVBXS"
   },
   "source": [
    "Place here a figure caption, explaining to the reader what the plot shows and how to interpret it."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "JDZ2OJ8EVDsp"
   },
   "source": [
    "Place here a description of the design decisions you made when creating the plot, and why. Which principles of good visual design were employed here?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "zNq9eHiXVET_"
   },
   "source": [
    "15. Make a **scatter plot (or set of scatter plots)** and describe it in the cells below. The plot should respect the principles of good visual design, and should demonstrate something interesting."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "J88yLZ08VpnU"
   },
   "outputs": [],
   "source": [
    "# place here the code to download/load, process and visualize the data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "8sWsJ024Vodd"
   },
   "source": [
    "Place here a figure caption, explaining to the reader what the plot shows and how to interpret it."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "QbdHHoGWVseF"
   },
   "source": [
    "Place here a description of the design decisions you made when creating the plot, and why. Which principles of good visual design were employed here?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "smm-E0bkVyET"
   },
   "source": [
    "16. Make a **bar, column or pie chart** and describe it in the cells below. The plot should respect the principles of good visual design, and should demonstrate something interesting."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "UcsMXJSFV5pm"
   },
   "outputs": [],
   "source": [
    "# place here the code to download/load, process and visualize the data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "BwdQTodVV6Py"
   },
   "source": [
    "Place here a figure caption, explaining to the reader what the plot shows and how to interpret it."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "uvBW3OQMV_qB"
   },
   "source": [
    "Place here a description of the design decisions you made when creating the plot, and why. Which principles of good visual design were employed here?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "fjtuaxQTWEZ0"
   },
   "source": [
    "17. Make a **histogram** and describe it in the cells below. The plot should respect the principles of good visual design, and should demonstrate something interesting."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "u-g_HHJVWHdK"
   },
   "outputs": [],
   "source": [
    "# place here the code to download/load, process and visualize the data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "v1eu-KG3WKk4"
   },
   "source": [
    "Place here a figure caption, explaining to the reader what the plot shows and how to interpret it.Place here a figure caption, explaining to the reader what the plot shows and how to interpret it."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "OAkvo5XRWMXQ"
   },
   "source": [
    "Place here a description of the design decisions you made when creating the plot, and why. Which principles of good visual design were employed here?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "W1o1y6fyWS3R"
   },
   "source": [
    "18. Finally, there is one last chart to make. For this problem, **make the worst graph you can using the same data as one of the good graphs above.** Break all the rules. Aim for something that still technically represents all of the right numbers while actually being totally misleading or unreadable. Prefer being misleading over merely unreadable."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "3eB0J9diWe4H"
   },
   "outputs": [],
   "source": [
    "# place here the code to download/load, process and (terribly) visualize the data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "bFCZg_rAWepw"
   },
   "source": [
    "Place here a description of the terrible design decisions you made when creating the plot, and why. Which principles of good visual design did you violate, and how?"
   ]
  }
 ],
 "metadata": {
  "colab": {
   "provenance": []
  },
  "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.12.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
