Gráficos de línea con intervalos de confianza usando relplot(). —-#
0:00 min | Última modificación: Octubre 13, 2021 | [YouTube]
[1]:
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
[2]:
fmri = sns.load_dataset("fmri")
display(
fmri.head(),
fmri.size
)
subject | timepoint | event | region | signal | |
---|---|---|---|---|---|
0 | s13 | 18 | stim | parietal | -0.017552 |
1 | s5 | 14 | stim | parietal | -0.080883 |
2 | s12 | 18 | stim | parietal | -0.081033 |
3 | s11 | 18 | stim | parietal | -0.046134 |
4 | s10 | 18 | stim | parietal | -0.037970 |
5320
[3]:
#
# Exisen diferentes medidas para cada sujeto,
# timepoint, .....
#
fmri[fmri.timepoint == 18].head()
[3]:
subject | timepoint | event | region | signal | |
---|---|---|---|---|---|
0 | s13 | 18 | stim | parietal | -0.017552 |
2 | s12 | 18 | stim | parietal | -0.081033 |
3 | s11 | 18 | stim | parietal | -0.046134 |
4 | s10 | 18 | stim | parietal | -0.037970 |
5 | s9 | 18 | stim | parietal | -0.103513 |
[4]:
#
# Gráfica por defecto mostrando los datos
#
sns.relplot(
x="timepoint",
y="signal",
data=fmri,
kind='scatter',
)
plt.show()
[5]:
#
# Representación de la incertidumbre
# =============================================================================
# Usa por defecto los intervalos de confianza del 95%
#
sns.relplot(
x="timepoint",
y="signal",
kind="line",
data=fmri,
)
plt.show()
[6]:
#
# Reemplazo de los ci por desviaciones estándar
#
sns.relplot(
x="timepoint",
y="signal",
kind="line",
ci="sd",
data=fmri,
)
plt.show()
[7]:
#
# Separación por clases usando colores.
#
sns.relplot(
x="timepoint",
y="signal",
hue="event",
kind="line",
data=fmri,
)
plt.show()
[8]:
#
# Separación por clases usando style
#
sns.relplot(
x="timepoint",
y="signal",
style="event",
kind="line",
data=fmri,
)
plt.show()
[9]:
#
# Separación por clases usando marcadores y linea.
#
sns.relplot(
x="timepoint",
y="signal",
style="event",
markers=True,
kind="line",
data=fmri,
)
plt.show()
[10]:
#
# Separación por clases usando solot marcadores.
#
sns.relplot(
x="timepoint",
y="signal",
style="event",
markers=True,
dashes=False,
kind="line",
data=fmri,
)
plt.show()
[11]:
#
# Separación basada en multiples elementos.
#
sns.relplot(
x="timepoint",
y="signal",
hue="region",
style="event",
dashes=False,
markers=True,
kind="line",
data=fmri,
)
plt.show()