Seaborn.choose_diverging_palette() method



Seaborn.choose_diverging_palette() method helps in launching a widget that enables easy access to the user in choosing a diverging palette.

This is equivalent to the function's diverging palette(). This type of palette works well for data that have a meaningful midpoint and range between fascinating low values and interesting high values.

This method can be executed in IPython 2+ versions used in the Jupyter notebook.

Syntax

Following is the syntax of the Seaborn.choose_diverging_palette() method −

seaborn.choose_diverging_palette(as_cmap=False)

Parameters

The parameters of the seaborn.choose_diverging_palette() method are as follows,

S.No Parameter and Description
1 As_cmap

This optional parameter takes Boolean values and if true returns a matplotlib colormap instead of a list of colors.

Return Value

This method returns either a list of colors or a matplotlib colormap. Now we will understand how this method works in the below example.

We can run the palette widget to access diverging palettes in seaborn using the following line of code,

sns.choose_diverging_palette(as_cmap=False)

Output

The output produced is shown in the image below.

seaborn_choose_diverging_palette_method

In the above image, there are different options that are part of the diverging_color_palette() in seaborn. Each of the methods parameters have progress bars in the widget so as to easy access. The center can have either light or dark and the dark centered palette is shown below.

choose_diverging_palette_method

In this way this method can be used to produce a widget which makes it easy for the user to adjust a palette according to their preferences rather than manually entering lines of code and numbers to check for the required palette.

seaborn_palette_widgets_introduction.htm
Advertisements