Point plots

Introduction to Data Visualization with Seaborn

Erin Case

Data Scientist

What are point plots?

  • Points show mean of quantitative variable
  • Vertical lines show 95% confidence intervals

Point plot of average bill of smokers vs. non-smokers

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Introduction to Data Visualization with Seaborn

Line plot: average level of nitrogen dioxide over time Line plot of nitrogen dioxide over time

Point plot: average restaurant bill, smokers vs. non-smokers Point plot of average bill of smokers vs. non-smokers

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Introduction to Data Visualization with Seaborn

Point plots vs. line plots

Both show:

  • Mean of quantitative variable
  • 95% confidence intervals for the mean

Differences:

  • Line plot has quantitative variable (usually time) on x-axis
  • Point plot has categorical variable on x-axis
Introduction to Data Visualization with Seaborn

Point plots vs. bar plots

Both show:

  • Mean of quantitative variable
  • 95% confidence intervals for the mean
Introduction to Data Visualization with Seaborn

Point plots vs. bar plots

Bar plot of masculinity with hue

Point plot of masculinity with hue

Introduction to Data Visualization with Seaborn

Creating a point plot

import matplotlib.pyplot as plt
import seaborn as sns

sns.catplot(x="age", 
            y="masculinity_important", 
            data=masculinity_data,
            hue="feel_masculine",
            kind="point")

plt.show()

Point plot of masculinity with hue

Introduction to Data Visualization with Seaborn

Disconnecting the points

import matplotlib.pyplot as plt
import seaborn as sns

sns.catplot(x="age", 
            y="masculinity_important", 
            data=masculinity_data,
            hue="feel_masculine",
            kind="point",
            join=False)

plt.show()

Point plot of masculinity with hue and points disconnected

Introduction to Data Visualization with Seaborn

Displaying the median

import matplotlib.pyplot as plt
import seaborn as sns

sns.catplot(x="smoker", 
            y="total_bill", 
            data=tips, 
            kind="point")

plt.show()

Point plot of average total bill for smokers vs. non-smokers

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Introduction to Data Visualization with Seaborn

Displaying the median

import matplotlib.pyplot as plt
import seaborn as sns
from numpy import median

sns.catplot(x="smoker", 
            y="total_bill", 
            data=tips, 
            kind="point", 
            estimator=median)

plt.show()

Point plot of median total bill for smokers vs. non-smokers

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Introduction to Data Visualization with Seaborn

Customizing the confidence intervals

import matplotlib.pyplot as plt
import seaborn as sns

sns.catplot(x="smoker", 
            y="total_bill", 
            data=tips, 
            kind="point",
            capsize=0.2)

plt.show()

Point plot with caps on confidence intervals

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Introduction to Data Visualization with Seaborn

Turning off confidence intervals

import matplotlib.pyplot as plt
import seaborn as sns

sns.catplot(x="smoker", 
            y="total_bill", 
            data=tips, 
            kind="point",
            ci=None)

plt.show()

Point plot with no confidence intervals

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Introduction to Data Visualization with Seaborn

Let's practice!

Introduction to Data Visualization with Seaborn

Preparing Video For Download...