How to create a Pie Chart in Seaborn?

To create a Pie Chart in Seaborn, you first need to create a dataframe containing the values for each slice of the pie. Then, you can use the seaborn.pieplot() function to create the chart. You can customize the chart by setting the labels, colors, and other parameters. Finally, you can use the plt.show() function to display the chart.


The Python data visualization library doesn’t have a default function to create pie charts, but you can use the following syntax in Matplotlib to create a pie chart and add a Seaborn color palette:

import matplotlib.pyplot as plt
import seaborn as sns

#define data
data = [value1, value2, value3, ...]
labels = ['label1', 'label2', 'label3', ...]

#define Seaborn color palette to use
colors = sns.color_palette('pastel')[0:5]

#create pie chart
plt.pie(data, labels = labels, colors = colors, autopct='%.0f%%')
plt.show()

Refer to the for a complete list of color palettes.

The following examples show how to use this syntax in practice.

Example 1: Pie Chart with Pastel Seaborn Color Palette

The following code shows how to create a pie chart using the ‘pastel‘ Seaborn color palette:

import matplotlib.pyplot as plt
import seaborn as sns

#define data
data = [15, 25, 25, 30, 5]
labels = ['Group 1', 'Group 2', 'Group 3', 'Group 4', 'Group 5']

#define Seaborn color palette to use
colors = sns.color_palette('pastel')[0:5]

#create pie chart
plt.pie(data, labels = labels, colors = colors, autopct='%.0f%%')
plt.show()

Example 2: Pie Chart with Bright Seaborn Color Palette

The following code shows how to create a pie chart using the ‘bright‘ Seaborn color palette:

import matplotlib.pyplot as plt
import seaborn as sns

#define data
data = [15, 25, 25, 30, 5]
labels = ['Group 1', 'Group 2', 'Group 3', 'Group 4', 'Group 5']

#define Seaborn color palette to use
colors = sns.color_palette('bright')[0:5]

#create pie chart
plt.pie(data, labels = labels, colors = colors, autopct='%.0f%%')
plt.show()

These two examples illustrate how to create a pie chart with two different Seaborn color palettes.

However, there are many more styles you could use. Refer to the for a complete list of color palettes.

x