python - 更改Seaborn的对线的回归线颜色

标签 python matplotlib seaborn

我想将回归线的颜色更改为另一种颜色。据我所知,我发现了一个关于联合图的类似问题,据我所知,它与pairplot并不相似。我附上一个例子:

import seaborn as sns; 
sns.set(style="ticks", color_codes=True)
iris = sns.load_dataset("iris")
g = sns.pairplot(iris, kind="reg")

最佳答案

您需要将plot_kws作为dict传递。您可以使用line_kws更改回归线。有关更多信息,请引用docs

import seaborn as sns
sns.set(style="ticks", color_codes=True)
iris = sns.load_dataset("iris")
g = sns.pairplot(iris, kind="reg", plot_kws={'line_kws':{'color':'red'}})
plt.show()

输出:

enter image description here

关于python - 更改Seaborn的对线的回归线颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50722972/

相关文章:

python - 如何删除嵌套字典中的所有空字段?

python - 使用热图居中表格

python , Windows : parsing command lines with shlex

python - C-Numpy : How to create fixed-width ndarray of strings from existing data

python - pandas - 箱线图中位数颜色设置问题

python - 使用 matplotlib 时如何在 X 轴上显示年份?

python - 在seaborn中用中值标记箱线图

python - 使用 Python 在同一图中绘制两个猫图

python - 如何在Python DataFrame上的同一列中连接相同的行名称

matplotlib - 注释框不会出现在 matplotlib 中