Home / Natural Language Processing

Word Cloud

Visualizing keyword importance through frequency-based spatial distribution.

Overview

What the picture encodes

Font size maps to frequency: the most common word is largest, and everything else is scaled relative to it. Position, colour and rotation almost always carry no information — they are chosen by a layout algorithm packing shapes into a space without overlap.

That is the first thing to know about reading one. Two words next to each other are not related; they simply fitted. Any interpretation based on adjacency or colour is reading structure that was never encoded.

Input Text

Parameters

40

Cloud View

Active

Statistics

Total Words 0
Unique Vocab 0
Filtered 0

Insight

Size represents term frequency ($tf$). Larger words appear more often in your source text.
Low Freq
High Freq

Word Cloud Generator: A Practical Guide

A word cloud sizes each word by how often it appears. It is genuinely useful for a first look at a corpus, and it is a frequency chart with the axes removed - which is worth knowing before drawing conclusions from one.

Why stopwords have to go

Run a word cloud on raw English text and you get the, of, and, to, a in enormous type. These are the most frequent words in almost any corpus and they tell you nothing about the subject.

Removing them is what makes the visualisation informative, and it is a genuine editorial choice rather than a technical detail. Standard stopword lists are a reasonable default; domain-specific ones usually matter more. In a corpus of medical papers, patient and study may be so ubiquitous that they crowd out everything that distinguishes one paper from another.

A frequency chart that happens to look like art

A word cloud draws each word at a size proportional to how often it appears. That is the whole visualisation: size encodes frequency, and everything else — colour, rotation, position — is decoration.

Which is worth stating plainly, because it sets both the use and the limits. It answers "what words dominate this text?" quickly and legibly, and it answers nothing else.

The pipeline behind one:

  1. Tokenise the text into words.
  2. Normalise — lowercase, strip punctuation.
  3. Remove stop words, or "the" and "and" will dominate every cloud ever made.
  4. Count the remaining words.
  5. Lay out the top n by size, fitting them into the available space.

Step 3 is what makes the difference between a useful cloud and a picture of English function words.

from wordcloud import WordCloud
from sklearn.feature_extraction.text import ENGLISH_STOP_WORDS

wc = WordCloud(width=1200, height=600, background_color="white",
               stopwords=set(ENGLISH_STOP_WORDS),
               max_words=100, collocations=False).generate(text)
wc.to_file("cloud.png")

collocations=False is worth knowing: by default the library includes two-word phrases, which is sometimes desirable and often produces duplicated content ("machine", "learning" and "machine learning" all present).

Why counts alone mislead

Raw frequency has a systematic bias: it favours words that are common in the language, not words that are distinctive to this text.

Remove stop words and the next tier takes over — "said", "one", "time", "people". A cloud of a thousand product reviews will prominently feature "product", which tells you nothing you did not already know.

TF-IDF weighting fixes this by dividing by how many documents contain each word, so terms appearing everywhere are suppressed and terms distinctive to this document are amplified:

from sklearn.feature_extraction.text import TfidfVectorizer

vec = TfidfVectorizer(stop_words="english", max_features=200)
scores = vec.fit_transform([text]).toarray()[0]
freqs = dict(zip(vec.get_feature_names_out(), scores))
WordCloud().generate_from_frequencies(freqs)

generate_from_frequencies is the function to know: it takes any dictionary of word-to-weight, so the sizes can encode TF-IDF, log-odds against a comparison corpus, or a sentiment score — anything more informative than a raw count.

The honest limitations

Word clouds are widely criticised in data visualisation, and the criticisms are correct:

Area is hard to compare. People judge length well and area poorly, so a word twice as frequent does not look twice as prominent. A bar chart of the top 20 terms conveys the same information far more precisely.

Long words look more important. "Implementation" occupies more space than "cost" at the same font size, so word length confounds the encoding.

Position is meaningless but reads as meaningful. Words near the centre appear more important, and the layout algorithm placed them there for packing reasons.

No context or relationships. "Not good" appears as "good". Negation, phrases and sentiment are all invisible.

Rotation hurts legibility for no informational gain.

So the fair summary: a word cloud is a reasonable first look at an unfamiliar corpus and a poor analytical tool. Use it to orient yourself, then use a bar chart, a keyness comparison or a topic model to say anything specific.

Interactive Exploration Guide

  1. Turn the filter off. Disable Stopwords Filter and press Generate. The cloud fills with function words and says nothing about the content — raw frequency is dominated by grammar, not meaning.
  2. Turn it back on. Enable the filter and regenerate. Content words emerge, and the picture becomes about the subject matter.
  3. Restrict the vocabulary. Set Max Words to 10 and generate. Only the strongest signals survive. Now raise it to 100 — the long tail of near-equal words adds visual noise without adding information.
  4. Regenerate without changing anything. Press Generate twice at the same settings. The layout shifts while the sizes stay the same, which shows directly that position carries no meaning.

Where raw frequency misleads, and what to use instead

Frequency alone conflates “important in this document” with “common in general”. The standard correction is TF-IDF, which weights a word by how often it appears in this document and divides by how many documents contain it at all:

tf-idf = tf(word, doc) × log(N / df(word))

A word appearing in every document gets an IDF near zero and drops out; a word frequent here and rare elsewhere scores highly. That is much closer to what people actually want a word cloud to show — what is distinctive about this text, not merely what is in it.

The other limitation is that area is a poor visual encoding. People judge length far more accurately than area, so a bar chart conveys the same data more precisely. The word cloud’s advantage is that it is quick to scan and shows many terms at once — useful for exploration, weak for comparison.

What usually goes wrong

  • Skipping normalisation. Without lowercasing and lemmatising, Run, run, running and ran are four separate entries splitting one word’s weight.
  • Comparing two clouds. Each is scaled to its own maximum, so a word the same size in two clouds may have very different counts. Comparison needs a shared scale, which means a chart.
  • Reading meaning into layout. Position and colour are decoration. Adjacency implies nothing.
  • Using raw counts on documents of different lengths. A longer document has larger counts throughout; normalise by length or use TF-IDF.

Key takeaway

A word cloud encodes frequency as font size and nothing else — position, colour and rotation are layout, not data. It needs stopword removal to say anything at all, and TF-IDF rather than raw frequency to show what is distinctive rather than merely common. Treat it as a fast exploratory glance at a corpus, and reach for a bar chart whenever the question is how much bigger one term is than another.

Better alternatives, by question

QuestionBetter tool
Which terms are most frequent?A horizontal bar chart of the top 20
Which terms distinguish A from B?Keyness or log-odds ratio, plotted
What topics are present?LDA or BERTopic, with top terms per topic
How does usage change over time?A line chart of term frequency by period
Which terms co-occur?A co-occurrence network graph
What is the sentiment?A sentiment model, not word counts

The second row deserves emphasis because it is the question people usually mean. Comparing two corpora — positive versus negative reviews, this year versus last — and plotting the terms with the largest difference in relative frequency is far more informative than two word clouds side by side, and it is a standard technique in corpus linguistics.

BERTopic is worth knowing as the modern option: embed the documents, cluster the embeddings, and extract distinguishing terms per cluster. It finds themes rather than words, and it handles the "not good" problem because embeddings are contextual.

When a word cloud is the right choice

Not never — there are cases where it genuinely fits:

Exploratory orientation. First contact with an unfamiliar corpus, to see what register and subject matter you are dealing with.

Presentation to a non-technical audience, where an immediately legible impression matters more than precision. It communicates "here is what this text is about" in one glance.

A visual element in a report or dashboard where the analytical content is carried by other charts.

What to do to make it as good as it can be: remove stop words aggressively, weight by TF-IDF rather than count, disable rotation, cap at 50–100 words, use a single colour or a colour that encodes something real, and put a bar chart of the top terms next to it.

Practical gotchas

  • Stop words are language-specific. An English list applied to French text leaves "le", "de" and "et" dominating.
  • Domain stop words matter too. In product reviews, "product", "item" and the brand name are noise; add them to the list.
  • Lemmatise or accept duplicates. "Run", "runs" and "running" appear as three words otherwise.
  • Watch for a dominating single term that compresses everything else to illegibility. A log scale on the weights helps.
  • Numbers and URLs usually want removing.
  • Font support. Non-Latin scripts need a font that contains them, or the cloud renders as boxes.

What a word cloud shows, and what it hides

A word cloud is a frequency count with a font size attached. Building one from raw counts and then from TF-IDF shows why the raw version almost always says the same thing regardless of the text.

example_01.pyNumPy
Output

Questions people ask

Are word clouds bad? They are imprecise, which is a real limitation for analysis and not disqualifying for orientation and presentation.

Should I remove stop words? Always, or the cloud shows the structure of the language rather than the content of the text.

Can I use TF-IDF instead of counts? Yes, via generate_from_frequencies, and it usually produces a much more informative cloud.

Does colour mean anything? By default no. You can map it to something real — sentiment, topic, part of speech — and then it does.

How many words should I show? 50–100. Beyond that the small words are unreadable and add nothing.

What about phrases? Bigrams can be included, and watch for the duplication that produces ("machine", "learning", "machine learning").

Recap in one screen

  • A word cloud encodes frequency as font size; everything else is decoration.
  • Remove stop words, or every cloud shows the same function words.
  • Weight by TF-IDF rather than raw count to surface what is distinctive rather than what is common.
  • Area comparison is imprecise and word length confounds it — a bar chart says the same thing more accurately.
  • Good for orientation and presentation; use keyness comparison or topic modelling for analysis.

Recall check

0 of 4

Say the answer out loud before you reveal it — recalling it is what makes it stick, and rereading it is not.

  1. What is meant by “Stop words are language-specific” here?

  2. What is meant by “Domain stop words matter too” here?

  3. What is meant by “Lemmatise or accept duplicates” here?

  4. What is meant by “Watch for a dominating single term” here?

Cheat sheet

Word Cloud Generator

Font size maps to frequency: the most common word is largest, and everything else is scaled relative to it. Position, colour and rotation almost always carry no information — they are chosen by a layout algorithm packing shapes into a space without overlap.

NLP · vizlearn.in/natural_language_processing/word_cloud.html

About the author

Ashish Jangra builds and maintains VizLearn. Every module here is written and the visualisation behind it hand-built, so the numbers in a readout come from the same code that draws the picture. Corrections are genuinely welcome and get priority over everything else — if a page states something wrong, or an animation misrepresents what the algorithm does, get in touch.