Appendix E — Seaborn tutorial#

WIP

See planned outline here https://docs.google.com/document/d/1fwep23-95U-w1QMPU31nOvUnUXE2X3s_Dbk5JuLlKAY/edit#bookmark=id.3i7cktuf1u3i

In this tutorial, we’ll learn about Seaborn data visualizations. We’ll discuss Seaborn plot functions

TODO: LIST / TABLE

We’ll also describe the various options for customize plots’ the appearance, add annotations, and export plots as publication-quality images.

If you want to pursue a career in a data-related field, I highly recommend you get to know Seaborn by reading this tutorial and the other resources in the links section.

Introduction to Seaborn#

import seaborn as sns
import pandas as pd
days = [1, 2, 3, 4]
cakes = [2, 5, 3, 4]
sns.lineplot(x=days, y=cakes)
<Axes: >
../_images/58b2402a0c54655f8dd5e4d34824cbe1a9147ce9fcba5400fe5d291976c7c575.png
# (optional) use Matplotlib axis methods to add labels
ax = sns.lineplot(x=days, y=cakes)
ax.set_xlabel("days")
ax.set_ylabel("cakes")
Text(0, 0.5, 'cakes')
../_images/6bb81d397ec713e95e0648dd75d30b5bf4701a07faa873d02b0f630d4261a7b4.png
df = pd.DataFrame({"days":days, "cakes":cakes})
df
days cakes
0 1 2
1 2 5
2 3 3
3 4 4
df.columns
Index(['days', 'cakes'], dtype='object')
sns.lineplot(x="days", y="cakes", data=df)
<Axes: xlabel='days', ylabel='cakes'>
../_images/6bb81d397ec713e95e0648dd75d30b5bf4701a07faa873d02b0f630d4261a7b4.png
# # ALT. hybrid approach
# sns.lineplot(x=df["days"], y=df["cakes"])