Seaborn.blend_palette() method



The Seaborn.blend_palette() method is used to blend between a list of colors. The number of colors to be blended can either be passed as arguments or the palette is blended in the sequence given to the method.

Syntax

Following is the syntax of the blend_palette() method −

seaborn.blend_palette(colors, n_colors=6, as_cmap=False, input='rgb')

Parameters

The parameters of this method are as follows −

S.No Parameter and Description
1 Color

Takes base color to high values and it is either a hex, an RGB tuple or an html color name.

2 N_color

Takes integer values and determines the number of colors in the palette. It is an optional parameter.

3 As_cmap

This optional parameter takes Boolean values and if true returns an matplotlib colormap.

Return value

This method returns a list of tuples or a matplotlib colormap.

Example 1

We will create a simple palette blended with different colors by passing a list of either hex values, html colors and or tuple in the input space. In this example, hex colors are passed.

import seaborn as sns
import matplotlib.pyplot as plt
sns.palplot(sns.blend_palette(["#FCF8E8","#94B49F","#DF7861","#76549A"], 15))
plt.show()

Output

The output is as follows −

seaborn_blend_palette_method

Example 2

In this example, we will pass a list of html colors and see how to do that. The following line of code can be sued to do so.

import seaborn as sns
import matplotlib.pyplot as plt
sns.palplot(sns.blend_palette(["teal","grey","silver","orange"], 15))
plt.show()

Output

The output is as follows −

blend_palette_method

Example 3

In this example, we will pass a tuple of colors and notice how to do that., the following line of code can be used to do so.

import seaborn as sns
import matplotlib.pyplot as plt
sns.palplot(sns.blend_palette(("blue","orange"), 15))
plt.show()

Output

The output is as follows −

blend_palette
seaborn_color_palettes_introduction.htm
Advertisements