The objects that seaborn functions return
Predict the output · Medium · §7.3 Layout and returned objects
This code checks what seaborn's Axes-level and Figure-level functions return. Predict what it prints when you run it.
Code
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
views = pd.DataFrame({
"week": [1, 2, 3, 1, 2, 3],
"course": ["Python"] * 3 + ["Stats"] * 3,
"minutes": [52, 48, 55, 40, 44, 39],
})
fig, ax = plt.subplots()
out = sns.lineplot(data=views, x="week", y="minutes", hue="course", ax=ax)
print(out is ax)
g = sns.relplot(data=views, x="week", y="minutes", col="course", kind="line")
print(type(g).__name__)
print(g.axes.shape)
print(g.figure is fig)Solve this problem in your browser
Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.