I would like to have the plot of the following command line:
import numpy as np, pandas as pd
import seaborn as sns; sns.set(style="white", color_codes=True)
tips = sns.load_dataset("tips")
g = sns.jointplot(x="total_bill", y="tip", data=tips, hue= 'sex')
if the parameter 'hue' was implemented in jointplot.
How can I do this?
Maybe superposing two joint plots?
This functionality was added in thev0.11 Seaborn release in September 2020 (see eg the release blog post or the documentation ).
The documentation now features a great example based on the penguins dataset:
penguins = sns.load_dataset("penguins")
sns.jointplot(data=penguins, x="bill_length_mm", y="bill_depth_mm", hue="species")
I further would like to give a minimal example for a Kernel density estimation in the joint plot (a 2d kdeplot ):
# optional: sns.set(style='darkgrid')
data = {'x': [1, 2, 3, 4, 5, 6],
'y': [2, 4, 1.5, 4, 3, 5],
'class': ['1', '1', '1', '0', '0', '0']}
sns.jointplot(data=data, x='x', y='y', hue='class', kind='kde',
fill=True, joint_kws={'alpha': 0.7})
You can't, unfortunately
and it won't be implemented in the near future, because the simplicity of jointplot should be preserved.
See here: https://github.com/mwaskom/seaborn/issues/365
You can only do it halfway (without the hist for both classes): Plotting two distributions in seaborn.jointplot
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.