1  Setting up Our plot

Data4All

Author

Ted Laderas, PhD

1.1 Motivation: Exploratory versus Explanatory

Exploratory analysis:

  • exploring and understanding the data, conducting the analysis

Explanatory analysis:

  • explaining your findings from your analysis in a coherent narrative that leads to a call to action

1.2 Effective Visual Communication

Focus on three techniques:

  • Decluttering your plot
  • Annotating your graph and data
  • Highlight data using Preattentive Attributes

1.3 Paper Doll Approach

  • We’re going to take a basic plot and dress it up
  • Modify its appearance to make our point more understandable and immediate

1.4 Dressing Up a Base Plot

We’ll start with a base plot that we’ll dress up. Here’s what that looks like.

Let’s save our plot into an R object called a ggplot. We’ll use the <- (left arrow) to assign it to the variable called my_plot:


library(ggplot2)
library(dplyr)

tv_shows <- read.csv("data/tv_shows.csv")

my_plot <-
ggplot(tv_shows) +
aes(x = seasonNumber, y= av_rating, group=title,
color = title) +
geom_line()

my_plot
_webr_editor_1 = Object {code: null, options: Object, indicator: Ke}

We need a few packages for Python. We need the pandas, seaborn, and matplotlib packages.

We will start by making a plot object with sns.lineplot():

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

tv_shows = pd.read_csv("data/tv_shows.csv")

sns.set_theme()
my_plot = sns.lineplot(data=tv_shows,
x="seasonNumber",
y="av_rating",
hue="title")

plt.show()
_pyodide_editor_2 = Object {code: null, options: Object, indicator: Ke}

1.5 Dressing up my_plot

Now, when we want to modify our plot, we can use my_plot. More on this in the next notebook. We’re basically going to add commands to modify our plot. I like to think of it as a paper doll approach: we are dressing our plot in different clothes.

my_plot
_webr_editor_3 = Object {code: null, options: Object, indicator: Ke}
sns.set_theme()
my_plot = sns.lineplot(data=tv_shows,
x="seasonNumber",
y="av_rating",
hue="title")

plt.show()
_pyodide_editor_4 = Object {code: null, options: Object, indicator: Ke}
Downloading Pyodide
Downloading webR