matplotlib
  1. matplotlib-pie-charts

Pie Charts - ( Basic Matplotlib )

Heading h2

Syntax

import matplotlib.pyplot as plt

labels = ['label1', 'label2', 'label3']
sizes = [10, 20, 70]
colors = ['red', 'green', 'blue']

plt.pie(sizes, labels=labels, colors = colors)
plt.show()

Example

import matplotlib.pyplot as plt

# define data
labels = ['Apples', 'Oranges', 'Bananas']
sizes = [30, 40, 30]

# plot pie chart
plt.pie(sizes, labels=labels)

# display plot
plt.show()

Output

A pie chart is displayed on the screen with labeled sections corresponding to the specified data.

Explanation

A Pie Chart is used to illustrate the compositions and proportions of different parts that make up a whole. It is a circular chart divided into slices or segments, which represent the proportion of the complete data set that each category holds.

In the example above, the matplotlib.pyplot module is used to plot a simple pie chart. The plt.pie() function takes in the sizes of different parts as a list, and an optional list of labels. The function then plots the pie chart with the specified labels and sizes.

Use

Pie charts are widely used in data visualization to represent the proportions of different parts that make up a whole. They are often used in business, finance, and marketing to represent market share, sales, and revenues.

Important Points

  • Pie charts are used to illustrate the compositions and proportions of different parts that make up a whole
  • The matplotlib.pyplot module can be used to plot pie charts
  • The plt.pie() function takes in the sizes of different parts as a list, and an optional list of labels
  • Pie charts are widely used in data visualization to represent market share, sales, and revenues

Summary

In conclusion, Pie Charts are a simple and effective way to represent proportions and compositions of different parts that make up a whole. The matplotlib.pyplot module provides an easy-to-use interface to plot pie charts with customizable labels and colors. It is widely used in business, finance, and marketing to represent market share, sales, and revenues.

Published on: