I would like to change the color of the regression lines to a different one. I found a similar question regarding a joint plot, however, as far as I know it is not analogical to the pairplot. I am attaching an example:
import seaborn as sns;
sns.set(style="ticks", color_codes=True)
iris = sns.load_dataset("iris")
g = sns.pairplot(iris, kind="reg")
To change the line color in seaborn linear regression jointplot, we can use joint_kws in jointplot() method.
A pairplot plot a pairwise relationships in a dataset. The pairplot function creates a grid of Axes such that each variable in data will by shared in the y-axis across a single row and in the x-axis across a single column.
This can be done by adding a palette argument inside the boxplot() function and giving it any predefined seaborn color palette value like “Set1”, “Set2”, “Paired”, “Set3” etc.
You need to pass plot_kws
as a dict. You can change the regression line with line_kws
. Refer to docs for more information.
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()
Output:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With