pythonregressionseaborn

How to show the regression line in seaborn linear regression jointplot


As described in the seaborn API the following code will produce a linear regression plot.

import seaborn as sns 
import matplotlib.pyplot as plt 
  
# loading dataset 
penguins = sns.load_dataset("penguins")
  
# draw jointplot with reg kind 
sns.jointplot(data=penguins, x="bill_length_mm", y="bill_depth_mm", kind="reg")

This is the regression plot

Unfortunately there is no regression line. How can I add a line like in the API?


Solution

  • I also tried to use regplot()

    sns.regplot(x="bill_length_mm", y="bill_depth_mm", data=penguins)
    

    But it also didn't show the line. But using it in combination with jointplot:

    sns.jointplot(data=penguins, x="bill_length_mm", y="bill_depth_mm", kind="reg")
    sns.regplot(x="bill_length_mm", y="bill_depth_mm", data=penguins)
    

    The result with the line