seaborn icon indicating copy to clipboard operation
seaborn copied to clipboard

suggestion: color parameter for sns.pairplot

Open jhncls opened this issue 2 years ago • 4 comments

(tested with dev version) sns.pairplot when no hue is present, now ignores the palette= parameter and doesn't accept color= (nor similar).

Example:

import seaborn as sns

iris = sns.load_dataset('iris')
sns.pairplot(iris, palette='Reds')

This uses matplotlib's default color cycle (default starting with blue) to color everything. sns.pairplot(iris, color='green') gives an error: TypeError: pairplot() got an unexpected keyword argument 'color'.

It could be handy to accept such color and use it for the pairplot. Changing the matplotlib color cycle is not straightforward for casual users, and will also influence subsequent plots.

jhncls avatar Jan 17 '22 10:01 jhncls

You can pass color to the plot_kws and diag_kws parameter dictionaries.

mwaskom avatar Jan 17 '22 13:01 mwaskom

sns.pairplot when no hue is present, now ignores the palette= parameter

When you say "now ignores" do you mean that it did not do this in the past?

mwaskom avatar Jan 17 '22 13:01 mwaskom

When you say "now ignores" do you mean that it did not do this in the past?

Oops. I suppose I meant "compared to using hue". It very probably never worked with color=.

plot_kws and diag_kws are indeed good alternatives. Although it looks useful to also add color= to the pairplot, it also will add an extra layer of complexity to the code, with the accompanying risks of something breaking in the future. Even adding it to the online documentation can lead to more confusion. Feel free to close the issue.

jhncls avatar Jan 17 '22 15:01 jhncls

I am open to the idea on the basis that jointplot does have a top-level color= kwarg that gets passed to both the joint and marginal subplots. So I would likely accept a pull request adding it.

mwaskom avatar Jan 17 '22 15:01 mwaskom