Point plots

Introduzione alla visualizzazione dei dati con Seaborn

Content Team

DataCamp

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/
Introduzione alla visualizzazione dei dati con 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/
Introduzione alla visualizzazione dei dati con 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
Introduzione alla visualizzazione dei dati con Seaborn

Point plots vs. bar plots

Both show:

  • Mean of quantitative variable
  • 95% confidence intervals for the mean
Introduzione alla visualizzazione dei dati con Seaborn

Point plots vs. bar plots

Bar plot of masculinity with hue

Point plot of masculinity with hue

Introduzione alla visualizzazione dei dati con 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

Introduzione alla visualizzazione dei dati con 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",
            linestyle="none")

plt.show()

Point plot of masculinity with hue and points disconnected

Introduzione alla visualizzazione dei dati con 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/
Introduzione alla visualizzazione dei dati con 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/
Introduzione alla visualizzazione dei dati con 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/
Introduzione alla visualizzazione dei dati con 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",
            errorbar=None)

plt.show()

Point plot with no confidence intervals

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Introduzione alla visualizzazione dei dati con Seaborn

Let's practice!

Introduzione alla visualizzazione dei dati con Seaborn

Preparing Video For Download...