# Pie and Doughnut Charts

Pie charts are one of them most commonly used charts for data visualization, primarily because they are as easy to create as they are to understand.

Technically defining, a pie chart is a statistical graph for plotting numerical proportions. The independent variable is plotted in clockwise or anticlockwise direction on the circular graph. The magnitude of the dependent variable is proportional to the length of the arc on the circumference of the graph. Radial lines are used to connect the arcs to the center of the circle, thus dividing the pie into slices.

The independent variable can assume a finite number of distinct values; the dependent variable, usually a percentage, can take any value between 0 and 100 percent.

## A simple example

Before we move on to talk more about the pie chart and the kind of data that can be plotted and analyzed using the pie chart, we'll see a simple example for this chart.

Take a look at the pie chart shown below, used to showcase product-wise sales for the last quarter in Harry's FashionMart:

This pie chart gives you a quick comparison between the sales of each category and the total sales of the last quarter. One look at this pie chart and it is easy to deduce the following points:

- A major portion of Harry's revenue comes from clothing, with shoes coming a close second.
- Together, clothing and shoes contribute to more than 50% of Harry's sales.
- Harry's sales and marketing team needs to work on increasing the sales for handbags, wallets, and accessories while also maintaining the sales for shoes and clothing.

This said, like all charts, it is important to determine if a pie chart is suitable to visualize your data. Forcing a chart to fit to your data can only result in poor data visualization and, consequently, incorrect data analysis.

The section below tells you the what and why about the type of data a pie chart should be used to showcase.

## Ideal use cases for pie charts

Pie charts are best used for visualizing data when:

**You need to do a part-to-whole data analysis.**
For a part-to-whole analysis, pie charts have been found to be better than the column and bar charts. They are also easy to understand by even users who don't have a statistics background and therefore are preferred for showcasing data meant for public consumption.

**You need only simple proportions and not specific percentages/values.**
When comparisons between approximations are enough for a discussion and you don't need to get into the specifics, pie charts are your best bet. They aren't just visually appealing, but also satisfy the ‘at a glance' requirement of data visualization better than other charts when studying proportions.

**You have a small number of categories to compare.**
One reason why we could easily make deductions from the sample pie chart shown above is the number of categories plotted on the chart. With just four categories plotted on the chart, it is easy to assess the proportion of each category. This makes data analysis a cake walk (or should we say a pie walk!). The general rule of thumb says that pie charts should be used when the number of categories is three or less than three. While sticking to having just three categories on a pie chart maybe a difficult proposition in some use cases, pie charts are best used when rendered uncluttered. A cluttered pie chart will make data analysis difficult.

**Your data adds up to a meaningful whole.**
An unsaid rule for using pie charts is to use them for data visualization when your data adds up to 100%. For example, if the above pie chart for Harry's FashionMart was used to plot data for just the clothing, shoes, and accessories categories, it would be an incomplete pie chart (because the sales then don't add up to 100%) and therefore, not an ideal use case for using one.

## Limitations of a pie chart

There are certain use cases for which you cannot/should not use pie charts and effective data visualization demands that you pay careful attention to these.

You should avoid using pie charts when:

- Your data values are not distinctly separated; data analysis using a pie chart becomes restricted when dealing with data points of similar sizes.
- You need to compare data for more than one metric.
- You need to showcase specific data values and facilitate a part-to-part comparison.
- Your data progresses in real-time.

## Examples of ideal use cases for a pie chart

We've seen one example of a pie chart and spoken at length about when you should use pie charts and when you should stay away from them. We'll walk through a few more examples to understand these ideas better.

**Example 1:**
Off late, there's been a lot of debate around the usefulness of a pie chart. Most people believe that the information showcased on a pie chart can be showcased, and showcased better, on a column or bar chart. Well, we aren't taking any sides here, but we'll just walk you through some examples that will establish the usefulness of the pie chart, certainly in compatible situations.

Let's revisit our earlier example to figure this out.

We'll render the pie chart again here, so that we save scrolling time!

We'll render the same information using a column 2D chart, as shown below:

Now, if you were asked if the sales for clothing were more than 50% of the total sales for the last quarter, which chart would give you the answer faster? The pie chart, isn't it?

Again, if you were to be asked if the sum of the sales of handbags and wallets, and accessories is greater than the sales of shoes, which chart would answer your question faster? The pie chart again, isn't it?

What we are trying to establish here with these examples is that every chart has a specific purpose and works well when used for its intended purpose. For example, let's say if you were asked to tell the sales for clothing–a specific or close to specific value, it will be the column chart that will give you your answer and not the pie chart.

**Example 2:**
We've said that the ideal use case for a pie chart is one that has three or less than three categories. But what if your data has categories more than that and you have to really use a pie chart? What do you do then?

There are two things that you can do here:

One, check that if the pie chart is plotted to show all your categories, is your data discernible enough for the reader. If it is, you can go ahead with it. For example, take a look at the chart below:

Although the chart has data for six categories, it is easy to read.

But if there is the slightest chance that it could confuse your reader, for example if the values are not distinct enough, then avoid.

For example, take a look at the chart below:

Too cluttered, no?

Two, see if you can collapse your categories and yet showcase meaningful information. In the two pie charts shown above, the one with six categories can be taken as the collapsed version of the one with 13 categories.

## Variants of the pie chart

The doughnut chart is a variant of the pie chart. While the two charts are quite similar in the way they look and function, the following features of the doughnut chart set them apart:

- The doughnut chart has a cut out center.
- The center of the doughnut chart can be used to render additional information like the total of all data values as well as the data value of the slice being hovered upon. In this case, then, rendering data labels and data values separately is not required.

Take a look at the sales data for Harry’s FashionMart, as in the pie chart above, rendered using a doughnut chart:

## More examples of pie charts

One scenario where pie charts are most favored is when you want to communicate results of a survey.

For example, let's say your office is hosting a lunch for all employees and needs to know their food preference (in terms of vegetarian and non-vegetarian). The pie chart below, created based on responses collected by the employees, gives you a clear picture of their preferences:

So now you know that while approximately half the employees will eat only vegetarian food and only a small number of people will eat only non-vegetarian food, there is also a significant number of people who will eat both.

While looking up for interesting examples of the pie chart, to find some innovative ways in which the pie chart can be used, we came an interesting way the pie chart was used that we'd like to share with you.

Source: https://imgflip.com/i/k3doi

This was a quick guide on the dos and don'ts of using pie charts. You can see more sample implementations of the pie chart here.