Seaborn.xkcd_palette() method



The Seaborn.xkcd_palette() method is used to make a palette with color names form the xkcd color survey. (to understand more about this the following link can be visited.

(https://xkcd.com/color/rgb/)

This method is just a simple wrapper around the seaborn.xkcd_rgb dictionary. That is it returns all the list of colors as RGB tuples in an object that behaves like to their seaborn color palettes.

Syntax

Following is the syntax of xkcd_palette() method –

seaborn.xkcd_palette(colors)

Parameters

The parameters of this method are described below.

S.No Parameter and Description
1 Colors

Takes a list of strings that are keys in the seaborn.xkcd_rgb dictionary.

Retun Value

The xkcd_palette() method returns a Seaborn color palette.

Example 1

We will have to pass a list of string which are the color names as input and then the colors are produced as a palette as output. The strings should be a part of the seaborn.xkcd_rgb dictionary.

import seaborn as sns
import matplotlib.pyplot as plt
data = sns.xkcd_palette(["forest green","mauve","teal","indigo"])
sns.palplot(data)
plt.show()

Output

The output is as follows −

seaborn_xkcd_palette_method

Example 2

In this example, we will pass some other colors and understand the different colors the dictionary has.

import seaborn as sns
import matplotlib.pyplot as plt
data = sns.xkcd_palette(["lilac","mauve","pale pink","sage"])
sns.palplot(data)
plt.show()

Output

the output is as follows,

xkcd_palette_method

Example 3

Let us see another example −

import seaborn as sns
import matplotlib.pyplot as plt
sns.xkcd_palette(["eggplant","mauve","steel blue","sage"])
sns.palplot(data)
plt.show()

Output

The output is as follows −

xkcd_palette
seaborn_color_palettes_introduction.htm
Advertisements