How add a plot to histogram in seaborn.jointplot?

0

 

To add a plot to a histogram in a seaborn jointplot, you can use the jointplot() function with the kind parameter set to 'hist' to create the histogram, and then add a plot using the jointplot() function with the kind parameter set to 'kde' or 'reg'.

Here's an example using the tips dataset from seaborn:


import seaborn as sns

# Load the tips dataset
tips = sns.load_dataset("tips")

# Create a jointplot with a histogram and a kernel density estimate
sns.jointplot(x="total_bill", y="tip", data=tips, kind="hist")
sns.jointplot(x="total_bill", y="tip", data=tips, kind="kde")

# Show the plot
plt.show()

This will create a jointplot with a histogram on the x-axis and y-axis, and a kernel density estimate plot added to both sides of the jointplot.

You can also use the jointplot() function with the kind parameter set to 'reg' to add a regression plot to the jointplot. For example:



import seaborn as sns

# Load the tips dataset
tips = sns.load_dataset("tips")

# Create a jointplot with a histogram and a regression plot
sns.jointplot(x="total_bill", y="tip", data=tips, kind="hist")
sns.jointplot(x="total_bill", y="tip", data=tips, kind="reg")

# Show the plot
plt.show()

This will create a jointplot with a histogram on the x-axis and y-axis, and a regression plot added to the jointplot.

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !