Fundamentals 6 min read

How to Show Legends and Percentages on Matplotlib Pie Charts

This article walks through a common Matplotlib pie‑chart issue—displaying color legends below the chart and showing percentages outside—by presenting the problem, solution screenshots, and concise explanations to help Python users implement the fix.

Python Crawling & Data Mining
Python Crawling & Data Mining
Python Crawling & Data Mining
How to Show Legends and Percentages on Matplotlib Pie Charts

Introduction

Hello, I am PiPi. Recently a member of the Python community asked a Matplotlib visualization question, which we will explore together.

Problem Description

The user wants to know how to:

Display a legend indicating what each color represents below a pie chart.

Show percentage values outside the pie chart.

These requirements were not easily found in existing documentation.

Solution

Community members Kelly and Yu Liang provided guidance. The following screenshots illustrate the steps to configure the pie chart using Matplotlib:

Matplotlib pie chart example
Matplotlib pie chart example

The key parameters involve setting labels, autopct, and legend options in the plt.pie() call. By adjusting these arguments, the legend appears below the chart and percentages are displayed outside.

Solution details
Solution details

Additional parameter references for Matplotlib were shared to help users fine‑tune the appearance.

Parameter guide
Parameter guide

Conclusion

This article presented a specific Matplotlib visualization problem, provided a step‑by‑step solution with code snippets and screenshots, and helped the community resolve the issue efficiently.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

PythonMatplotlibdata-visualizationpercentagelegendpie-chart
Python Crawling & Data Mining
Written by

Python Crawling & Data Mining

Life's short, I code in Python. This channel shares Python web crawling, data mining, analysis, processing, visualization, automated testing, DevOps, big data, AI, cloud computing, machine learning tools, resources, news, technical articles, tutorial videos and learning materials. Join us!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.