I would like to change colors in this plot, it visualizes data properly but as you can see it isn't easy to read because all this colors are very similar (7 classes). Is there simple way to do it? Code for generating plot:
sns.pairplot(data, kind="scatter", hue = "Class")

You can use the optional argument palette, such as in (see here):
sns.pairplot(data, kind="scatter", hue = "Class", palette = "Paired")
In this case, I chose the color palette "Paired", but there are many others. You could also use:
sb.set_palette("dark")
sns.pairplot(data, kind="scatter", hue = "Class")
You can learn more about the available color palettes in the Seaborn site, https://seaborn.pydata.org/tutorial/color_palettes.html.
As is mentioned in some other answers, Seaborn doesn't always use the color palette setting when plotting. For example, when using histplot for a 2D scatter plot, I was always stuck with the rocket color palette, which is a boring blue. What I wanted was color scaling based on the density in each 2D bin. One can fix this with the cmap option. Here's an example using housing data that creates a pretty rainbow colormap.
import pandas as pd
import seaborn as sns
url = 'data/ames-housing-dataset.zip'
housing = pd.read_csv(url, engine='pyarrow', dtype_backend='pyarrow')
sns.histplot(
housing, x="1st Flr SF", y="SalePrice",
bins=30, discrete=(False, False), log_scale=(False, False),cbar=True,
hue_norm=True, cmap="viridis"
)
Below is the result. I hope that's helpful.

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