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.
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:
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.
Additional parameter references for Matplotlib were shared to help users fine‑tune the appearance.
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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
