"Crafting Pie Charts with Text: A Step-by-Step Guide"

Gregory Jul 09, 2026

Creating a pie chart with words, also known as a word cloud or tag cloud, is an engaging way to visualize data or ideas. Unlike traditional pie charts that use numbers and percentages, word clouds use the size of words to represent frequency or importance. Here's a step-by-step guide on how to make a pie chart with words using Python and the popular libraries, WordCloud and matplotlib.

Pie Chart Generator with percentages online
Pie Chart Generator with percentages online

Before we dive into the code, ensure you have the necessary libraries installed. You can install them using pip:

an info sheet with some text on it
an info sheet with some text on it

Setting Up the Environment

First, let's install the required libraries if you haven't already.

Small Group and Intervention Math Kit - Instructional Resources - Measurement, Time, Money, and Data - Graphing - Parts of a Pie Chart
Small Group and Intervention Math Kit - Instructional Resources - Measurement, Time, Money, and Data - Graphing - Parts of a Pie Chart

```python pip install wordcloud matplotlib ```

Importing Necessary Libraries

How to Make a Pie Chart in Canva (With Custom Colors & Labels)
How to Make a Pie Chart in Canva (With Custom Colors & Labels)

Once installed, import the required libraries in your Python script.

```python from wordcloud import WordCloud import matplotlib.pyplot as plt ```

Preparing Your Data

Understanding and Explaining Charts and Graphs
Understanding and Explaining Charts and Graphs

Word clouds work best with textual data. You can use a simple list of words, a sentence, or even a large corpus of text.

For this example, let's use a list of words representing different types of fruits.

Creating a List of Words

Title: Favorite Sport Pie Chart
Title: Favorite Sport Pie Chart

```python words = ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig', 'grape', 'honeydew', 'kiwi', 'lemon'] ```

Combining Words into a Single String

How to make a pie chart in google sheets with numbers
How to make a pie chart in google sheets with numbers
Pie Chart Resources | Spire Maths
Pie Chart Resources | Spire Maths
How to Make a Pie Chart in Excel (Only Guide You Need)
How to Make a Pie Chart in Excel (Only Guide You Need)
a pie chart with the words in class i think
a pie chart with the words in class i think
three pies with the words weekend in college and expectations on them, all labeled in different colors
three pies with the words weekend in college and expectations on them, all labeled in different colors
Year 7 Completing Tables from Pie Charts Worksheet
Year 7 Completing Tables from Pie Charts Worksheet
Describing bar charts about reading habits
Describing bar charts about reading habits
circle graph, pie graph, pie chart, sector graph
circle graph, pie graph, pie chart, sector graph
a pie chart with the words time spent in shower on it and other things around it
a pie chart with the words time spent in shower on it and other things around it
a pie chart with the words what team building exercises are supposed teach me
a pie chart with the words what team building exercises are supposed teach me
an image of someone's daily life planner on their cell phone, with the text
an image of someone's daily life planner on their cell phone, with the text
How to Draw a Pie Chart Mathscast
How to Draw a Pie Chart Mathscast
an open notebook with a pie chart on it
an open notebook with a pie chart on it
a pie chart with the words uses of google
a pie chart with the words uses of google
a pie chart with the words how awkward moments work on it, and an image of someone
a pie chart with the words how awkward moments work on it, and an image of someone
a pie chart with the words content of a pop song
a pie chart with the words content of a pop song
a pie chart with the words, my thoughts during class
a pie chart with the words, my thoughts during class
a pie chart with the words what do i think i break something? and an image of
a pie chart with the words what do i think i break something? and an image of
a pie chart that says things i do when i have to study
a pie chart that says things i do when i have to study

WordCloud requires a single string of text, so we'll combine our list of words into one.

```python text = ' '.join(words) ```

Generating the Word Cloud

Now that we have our data prepared, we can generate the word cloud.

Initializing the WordCloud Object

```python wc = WordCloud() ```

Generating the Word Cloud

```python wordcloud = wc.generate(text) ```

Visualizing the Word Cloud

Finally, let's visualize our word cloud using matplotlib.

Displaying the Word Cloud

```python plt.figure(figsize=(10, 7)) plt.imshow(wordcloud, interpolation='bilinear') plt.axis('off') plt.show() ```

And there you have it! You've created a pie chart with words using Python. The size of each word in the cloud represents the frequency of that word in the input text. You can customize the word cloud further by adjusting parameters like color, background color, font, and more. Happy coding!