Building custom color palettes

To build custom palettes, we first need to create a list and assign the colors we want to it, as follows:

my_palette = ['#4B0082', '#0000FF', '#00FF00', '#FFFF00', '#FF7F00',   '#FF0000']sns.set_palette(my_palette)sns.palplot(sns.color_palette())

The output is as follows:

In the preceding screenshot, we created a new palette called my_palette with seven colors. We then set the palette to our newly created palette, which shows us what the colors look like.

Let's see how our plot looks with our new custom palette using the following command:

sns.boxplot(data=df);

The output from the preceding command should look ...

Get Mastering Exploratory Analysis with pandas now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.