Dual-Variable FacetGrid Visualization

Use the ‘exercise’ dataset. Create a FacetGrid that visualizes the relationship between ‘pulse’ and ‘time’, separating data based on ‘kind’ and ‘diet’.

Example Output:

Use sns.FacetGrid along with the map function, specifying the col and row parameters.

import seaborn as sns
import matplotlib.pyplot as plt

def plot_facetgrid_two_variables():
    exercise_data = sns.load_dataset('exercise')
    g = sns.FacetGrid(exercise_data, col="diet", row="kind")
    g.map(plt.scatter, "pulse", "time")



© Let’s Data Science


Unlock AI & Data Science treasures. Log in!