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/83530663e0bb169bc89130aabcf12ccb6279e1b5e28b833036394d473cebd989.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/059764cc6f96c35be480693047cf11475bf82fc79bb0e847fb7f3d71542c669f.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/059764cc6f96c35be480693047cf11475bf82fc79bb0e847fb7f3d71542c669f.png
# # ALT. hybrid approach
# sns.lineplot(x=df["days"], y=df["cakes"])