I have this code slightly modified from here :
import seaborn as sns
sns.set(style="darkgrid")
tips = sns.load_dataset("tips")
color = sns.color_palette()[5]
g = sns.jointplot("total_bill", "tip", data=tips, kind="reg", stat_func=None,
xlim=(0, 60), ylim=(0, 12), color='k', size=7)
g.set_axis_labels('total bill', 'tip', fontsize=16)
and I get a nice looking plot - However, for my case I need to be able to change the color AND format of each individual point.
I've tried using the keywords, marker, style, and fmt, but I get the error TypeError: jointplot() got an unexpected keyword argument.
What is the correct way to do this? I'd like to avoid calling sns.JointGrid and plotting the data and marginal distributions manually..
Solving this problem is almost no different than that from matplotlib (plotting a scatter plot with different markers and colors), except I wanted to keep the marginal distributions:
import seaborn as sns
from itertools import product
sns.set(style="darkgrid")
tips = sns.load_dataset("tips")
color = sns.color_palette()[5]
g = sns.jointplot("total_bill", "tip", data=tips, kind="reg", stat_func=None,
xlim=(0, 60), ylim=(0, 12), color='k', size=7)
#Clear the axes containing the scatter plot
g.ax_joint.cla()
#Generate some colors and markers
colors = np.random.random((len(tips),3))
markers = ['x','o','v','^','<']*100
#Plot each individual point separately
for i,row in enumerate(tips.values):
g.ax_joint.plot(row[0], row[1], color=colors[i], marker=markers[i])
g.set_axis_labels('total bill', 'tip', fontsize=16)
Which gives me this:

The regression line is now gone, but this is all I needed.
所有评论(0)