Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Read by thought-leaders and decision-makers around the world. Phone Number: +1-650-246-9381 Email: [email protected]
228 Park Avenue South New York, NY 10003 United States
Website: Publisher: https://towardsai.net/#publisher Diversity Policy: https://towardsai.net/about Ethics Policy: https://towardsai.net/about Masthead: https://towardsai.net/about
Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Founders: Roberto Iriondo, , Job Title: Co-founder and Advisor Works for: Towards AI, Inc. Follow Roberto: X, LinkedIn, GitHub, Google Scholar, Towards AI Profile, Medium, ML@CMU, FreeCodeCamp, Crunchbase, Bloomberg, Roberto Iriondo, Generative AI Lab, Generative AI Lab Denis Piffaretti, Job Title: Co-founder Works for: Towards AI, Inc. Louie Peters, Job Title: Co-founder Works for: Towards AI, Inc. Louis-François Bouchard, Job Title: Co-founder Works for: Towards AI, Inc. Cover:
Towards AI Cover
Logo:
Towards AI Logo
Areas Served: Worldwide Alternate Name: Towards AI, Inc. Alternate Name: Towards AI Co. Alternate Name: towards ai Alternate Name: towardsai Alternate Name: towards.ai Alternate Name: tai Alternate Name: toward ai Alternate Name: toward.ai Alternate Name: Towards AI, Inc. Alternate Name: towardsai.net Alternate Name: pub.towardsai.net
5 stars – based on 497 reviews

Frequently Used, Contextual References

TODO: Remember to copy unique IDs whenever it needs used. i.e., URL: 304b2e42315e

Resources

Take our 85+ lesson From Beginner to Advanced LLM Developer Certification: From choosing a project to deploying a working product this is the most comprehensive and practical LLM course out there!

Publication

3 Reasons You Should Avoid Pie Plots At All Costs
Latest

3 Reasons You Should Avoid Pie Plots At All Costs

Last Updated on January 11, 2023 by Editorial Team

Author(s): Filipe Filardi

Originally published on Towards AI.

3 Reasons You Should Avoid Pie Plots At AllΒ Costs

The case against pie plots and a look at the alternatives

Prompt used: Pie Plot | Created by Author using Stable Diffusion

Pie Plots are a popular choice for data visualization because they are easy to create and understand. However, there are three main reasons you should avoid using PieΒ Plots.

3. They can be difficult to read accurately

One of the main problems with pie plots is that it can be difficult for the human eye to compare the slices' sizes accurately. This is because the angles of the slices are not a good representation of the proportions beingΒ shown.

Here’s an example of a Pie Plot in which you can’t comprehend the difference between the small categories visually:

Example of a difficult to read Pie Plot | Image byΒ Author

You can reproduce the plot with the following code:

import matplotlib.pyplot as plt

plt.figure(figsize=(8, 5))
plt.pie(
x=[350, 55, 50, 45, 40, 35],
labels=['Category 1', 'Category 2', 'Category 3', 'Category 4', 'Category 5', 'Category 6'],
colors=['#DDCC77', '#CC6677', '#44AA99', '#88CCEE', '#882255', '#AA4499']
)

plt.show()

Some say Donut Plots (Pie Plots with a hole in the center) can be easier to read because the viewer is not required to compare angles. But at best, it will make it a little easier for similar segments. You still won’t be able to compare proportions!

Example of the same plot but with a Donut Plot | Image byΒ Author

To create a Donut Plot, you can use the pie() function with the additional wedgeprops argument:

import matplotlib.pyplot as plt

plt.figure(figsize=(8, 5))
plt.pie(
x=[350, 55, 50, 45, 40, 35],
labels=['Category 1', 'Category 2', 'Category 3', 'Category 4', 'Category 5', 'Category 6'],
colors=['#DDCC77', '#CC6677', '#44AA99', '#88CCEE', '#882255', '#AA4499'],
wedgeprops={'width': 0.4}
)

plt.show()

2. They can be misleading

Another issue with pie plots is that they can be easily manipulated to give a false impression of the data. Can you tell which category has the biggest values in the following plots?

3 Pie Plots with different proportions but similar looks | Image byΒ Author

If you can’t tell by looking, you can imagine how these plots can be used to manipulate information, especially when they’re plotted side by side, like in the exampleΒ above.

You can check the values for each plot and reproduce them with the following code:

import matplotlib.pyplot as plt

fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(15, 8))

ax1.pie(
x=[25, 30, 30],
labels=['Category 1', 'Category 2', 'Category 3'],
colors=['#DDCC77', '#CC6677', '#44AA99']
)

ax2.pie(
x=[25, 25, 30],
labels=['Category 1', 'Category 2', 'Category 3'],
colors=['#DDCC77', '#CC6677', '#44AA99']
)

ax3.pie(
x=[25, 30, 35],
labels=['Category 1', 'Category 2', 'Category 3'],
colors=['#DDCC77', '#CC6677', '#44AA99']
)

ax1.set_title('Pie Plot 1')
ax2.set_title('Pie Plot 2')
ax3.set_title('Pie Plot 3')

plt.show()

1. There are better alternatives

You have a whole gallery of easier-to-read plots in your disposition. For example, Bar Plots can show proportions and be much easier to read and interpret than PieΒ Plots.

The same example in section two, but using bar plots | Image byΒ Author

They allow the viewer to quickly compare the bars' sizes, which was impossible before with PieΒ Plots.

You can reproduce the bar plots with the following code:

import matplotlib.pyplot as plt

fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(15, 8))

ax1.bar(
x=['Category 1', 'Category 2', 'Category 3'],
height=[25, 30, 30],
color=['#DDCC77', '#CC6677', '#44AA99']
)

ax2.bar(
x=['Category 1', 'Category 2', 'Category 3'],
height=[25, 25, 30],
color=['#DDCC77', '#CC6677', '#44AA99']
)

ax3.bar(
x=['Category 1', 'Category 2', 'Category 3'],
height=[25, 30, 35],
color=['#DDCC77', '#CC6677', '#44AA99']
)

ax1.set_title('Bar Plot 1')
ax2.set_title('Bar Plot 2')
ax3.set_title('Bar Plot 3')

plt.show()

Let’s face it. It is difficult to interpret PieΒ Plots!

When the segments are similar in size, it is almost impossible to determine which is the largest. When they are not similar, the best you can do is determine that one is larger than the other, but not by howΒ much.

It’s worth mentioning that 3D Pie charts are even worse! They distort the information of a 2D Pie Plot, making segments visually incomparable.

I hope this article has helped you to understand why we need to be careful when reading Pie Plots and why we should avoid usingΒ them.

If you’re interested in reading other articles written by me. Check out my repo with all articles I’ve written so far, separated by categories.

Thanks forΒ reading


3 Reasons You Should Avoid Pie Plots At All Costs was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.

Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming aΒ sponsor.

Published via Towards AI

Feedback ↓