Plot guides › Chart types

Pie chart

A pie chart shows parts of a whole as slices. It works for two or three parts where one is clearly dominant; for anything more detailed, a bar chart is easier to read.

Example pie chart made with matplotlib
Rendered from the code below, with example data.

When to use it

Watch out: People compare angles poorly. With many slices, or slices of similar size, use a sorted bar chart.

Ask for it in pltchat

Upload your file and type something like:

"pie chart of market share with percentage labels"

pltchat writes the loader and the plot for your columns, runs it in your browser and shows you the code.

The matplotlib code

Self-contained with example data; swap in pd.read_csv(...) or pd.read_excel(...) for your own file.

import matplotlib.pyplot as plt

labels = ["Product A", "Product B", "Product C", "Other"]
share = [52, 24, 15, 9]

fig, ax = plt.subplots(figsize=(5, 4))
ax.pie(share, labels=labels, autopct="%1.0f%%", startangle=90,
       counterclock=False, wedgeprops={"edgecolor": "w"})
ax.set_title("Market share 2024")
plt.tight_layout()
plt.show()

Make this with your data

Upload a CSV, Excel, JSON or Parquet file. Your first plot is always free.

Related plots