Warm tip: This article is reproduced from serverfault.com, please click

python-如何更改Seaborn Lmplot中的线条颜色

(python - How to change the line color in seaborn lmplot)

发布于 2016-03-06 13:15:44

我们可以得到下面的情节

import numpy as np, pandas as pd; np.random.seed(0)
import seaborn as sns; sns.set(style="white", color_codes=True)
tips = sns.load_dataset("tips")
g = sns.lmplot(x="total_bill", y="tip", data=tips)
sns.plt.show()

在此处输入图片说明

但是,当我们有大量数据点时,回归线不再可见。如何更改线条的颜色?我找不到命令

Questioner
Edward
Viewed
11
mgc 2016-03-06 21:35:40

你可以给参数作为键值对(字典)到底层plt.plot,并plt.scatter用功能line_kwsscatter_kws所以类似的事情line_kws = {'color': 'red'}应该做的工作:

g = sns.lmplot(x="total_bill", y="tip",
               data=tips, line_kws={'color': 'red'})
sns.plt.show()