{ "cells": [ { "cell_type": "markdown", "id": "3b84ddbc-2079-48c9-a38b-b0a34abd6d27", "metadata": {}, "source": [ "# Introduction to Seaborn" ] }, { "cell_type": "markdown", "id": "bbbcdd64-9f9f-4114-9359-20b24436dd62", "metadata": {}, "source": [ "The definition of seaborn's website is so concise that we replicate it here:\n", "\n", "\"Seaborn is a library for making statistical graphics in Python. It builds on top of matplotlib and integrates closely with pandas data structures.\"\n", "\n", "That's it! The main benefit of using it is that it is a more high-level library, which means we can achieve sophisticated plots with much less lines of code. Most axes style customization are done automatically. It can automatically provide plots with summary statistics." ] }, { "cell_type": "code", "execution_count": 1, "id": "ec137599-b8bd-4666-b5f7-13e94243b50e", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import seaborn as sns" ] }, { "cell_type": "markdown", "id": "ee542235-d3e1-485a-aa65-ac410c6d558c", "metadata": {}, "source": [ "We will apply the seaborn default theme, but you can choose others [here](https://seaborn.pydata.org/tutorial/aesthetics.html#seaborn-figure-styles)." ] }, { "cell_type": "code", "execution_count": 2, "id": "4e5f2908-a83c-4342-9690-eb55abdb0e37", "metadata": {}, "outputs": [], "source": [ "sns.set_theme()" ] }, { "cell_type": "markdown", "id": "1e2c1579-8df5-4e70-bd10-8a6095f2d564", "metadata": {}, "source": [ "## Scatter plots with seaborn" ] }, { "cell_type": "markdown", "id": "88932903-b980-42a3-b6e8-3f42327735c6", "metadata": {}, "source": [ "Let's load the same dataframe." ] }, { "cell_type": "code", "execution_count": 3, "id": "c0a502d8-9181-47b4-8e6b-63b37ed3a8d4", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | area | \n", "intensity_mean | \n", "major_axis_length | \n", "minor_axis_length | \n", "aspect_ratio | \n", "file_name | \n", "
---|---|---|---|---|---|---|
0 | \n", "139 | \n", "96.546763 | \n", "17.504104 | \n", "10.292770 | \n", "1.700621 | \n", "20P1_POS0010_D_1UL | \n", "
1 | \n", "360 | \n", "86.613889 | \n", "35.746808 | \n", "14.983124 | \n", "2.385805 | \n", "20P1_POS0010_D_1UL | \n", "
2 | \n", "43 | \n", "91.488372 | \n", "12.967884 | \n", "4.351573 | \n", "2.980045 | \n", "20P1_POS0010_D_1UL | \n", "
3 | \n", "140 | \n", "73.742857 | \n", "18.940508 | \n", "10.314404 | \n", "1.836316 | \n", "20P1_POS0010_D_1UL | \n", "
4 | \n", "144 | \n", "89.375000 | \n", "13.639308 | \n", "13.458532 | \n", "1.013432 | \n", "20P1_POS0010_D_1UL | \n", "