WordCloud

WordCloud[{s1,s2,}]

generates a word cloud graphic in which the si are sized according to their multiplicity in the list.

WordCloud[{w1s1,}]

generates a word cloud in which the si are sized according to the weights wi.

WordCloud[s1w1,]

also generates a word cloud in which the si are sized according to the weights wi.

WordCloud[{w1,w2,}{s1,s2,}]

also generates a word cloud in which the si are sized according to the weights wi.

WordCloud[{{s1,w1},{s2,w2},}]

also generates a word cloud in which the si are sized according to the weights wi.

WordCloud[data,shape]

fits the word cloud into the region defined by shape.

Details and Options

  • Word clouds are also known as tag clouds and are often used to visualize popularity of phrases or words in a given context.
  • The si can be strings or any other expression. They are rendered in the word cloud however they would normally be displayed.
  • WordCloud returns a Graphics object where each object si is displayed with linear dimensions proportional to its weight.
  • WordCloud["string"] generates a word cloud of the words in "string".
  • Each of the si can be given a symbol wrapper, which affects its behavior or rendering:
  • Annotation[si,label]provide an annotation
    Button[si,action]define an action to execute when clicked
    EventHandler[si,]define a general event handler
    Hyperlink[si,uri]create a hyperlink
    PopupWindow[si,cont]attach a popup window
    Rotate[si,θi]rotate by θi radians
    StatusArea[si,label]display in the status area when moused over
    Style[si,]show using the specified styles
    Tooltip[si,label]attach an arbitrary tooltip
  • Data not given in the form above is taken to be missing and will be ignored.
  • The cloud shape mask can be given in the following forms:
  • imagenonzero pixels of an Image object
    graphicsnonzero pixels of a rasterized Graphics object
    regionany 2D geometric RegionQ object
  • WordCloud has the same options as Graphics, with the following additions and changes:
  • BackgroundTransparentbackground color to use
    ColorFunctionAutomaticcolor based on weight and word
    ColorFunctionScalingTruewhether to scale weight argument of ColorFunction
    FontFamily"Helvetica"the family of font to use
    FontSizeAutomaticrange of font sizes
    FontTracking"Plain"the compression of characters
    FontWeightPlainthe weight of characters to use
    IgnoreCaseTruewhether to ignore case when computing multiplicities
    MaxItemsAutomaticmaximum number of words to show
    PlotRangeAutomaticrange of values to include
    PlotTheme$PlotThemeoverall theme for the plot
    PreprocessingRulesAutomatichow to pre-process specific elements
    RandomSeedingAutomaticspecify the seeding for random word orientation
    ScalingFunctionsIdentityscaling of the weights
    WordOrientation"Horizontal"orientation of the words to use
    WordSelectionFunctionAutomaticfunction to determine whether to include a word
    WordSpacingsAutomaticspace to add around each word
  • With ImageSizeAutomatic, the actual font sizes used are specified by FontSize, and the computed ImageSize will vary to fit the word cloud.
  • With ImageSize fully specified, rescaled font sizes are used so that the resulting word cloud will fit in the specified image size.
  • ScalingFunctions is applied to weights wi, with settings:
  • Identity,Noneno scaling function (default)
    Loglogarithmic scaling
    #^alpha&power scaling
    fuse the scaling function f
  • FontSize can be used to control font sizes from scaled weights with settings:
  • Automaticautomatically computed min and max size
    maxautomatically computed min size
    {min,max}explicit min and max size
    gexplicit mapping g between scaled weights and font size
  • PreprocessingRules can be used to specify how to transform individual words. If the weights are not specified, the preprocessing happens before counting.
  • Using WordSelectionFunction->f, the function f takes the words as the first argument. Optionally, the corresponding weight can be given to f as the second argument:
  • #Word or #1the word si
    #Weight or #2the weight wi

Examples

open allclose all

Basic Examples  (3)

Word cloud of weighted strings:

Tooltip every word of the word cloud:

Create a word cloud using a given shape:

Scope  (6)

Data  (4)

Word cloud of a list of strings:

Word cloud of a list of strings and weights:

Word cloud of an association:

Word cloud of a single string:

Shape  (1)

Create a word cloud of country names weighted by their area:

By default, WordCloud attempts to create a cloud of a rectangular shape:

Define the shape using Graphics primitives:

Define the shape as a region:

Use disconnected regions:

Presentation  (1)

Words are automatically styled to be distinct:

Change the font:

Change style for a particular word:

Change the color function:

Change the background color:

Use a plot theme:

Create a monochrome word cloud:

Options  (25)

Background  (1)

The default background of the word cloud is transparent:

Specify a different color:

ColorFunction  (1)

The default color function is ColorData["DarkRainbow"]:

Use a custom color function:

Use a single color:

Use shades of a single color:

Pick random colors from a specified color gradient:

ColorFunctionScaling  (2)

By default, weights are scaled to fit in the range 0 and 1:

Scaled weights are not suitable when used with indexed colors:

Use ColorFunctionScaling->False:

FontFamily  (1)

The default font family used is "Helvetica":

Use a different font family:

FontSize  (4)

The default font size is computed automatically:

Specify a maximum size:

Specify both a minimum and a maximum size:

Specify a custom mapping between weights and font size:

FontTracking  (1)

The default is FontTracking->"Plain":

Use a more expanded setting:

FontWeight  (1)

The font weight is Plain by default:

Use bold fonts:

IgnoreCase  (3)

By default, cases are ignored:

Differentiate between uppercase and lowercase letters:

With weighted strings and IgnoreCase->True, the total weight of the identical words is used:

With IgnoreCase->True, each word appears using the capitalization of its first occurrence:

ImageSize  (1)

ImageSize controls the display size only. The default display size is computed automatically:

Specify a different display size:

MaxItems  (1)

By default, up to 100 elements are shown in the cloud:

Specify a different amount:

PlotTheme  (1)

Create a word cloud with a specific theme:

PreprocessingRules  (3)

Specify the default processing rules:

Default styles are used for any word that is not preprocessed:

Perform spell correction before displaying strings:

ScalingFunctions  (1)

By default, font sizes are taken to be proportional to weights:

Use logarithmic scaling:

Use inverted weights to highlight countries with small populations:

WordOrientation  (1)

A word cloud with random orientations:

Randomly select from two given orientations:

WordSelectionFunction  (2)

Select strings based on their length:

By default, elements are selected based on decreasing weight order up to the MaxItems value:

Use a custom selection function:

Include the element weight in the selection criterion:

WordSpacings  (1)

By default, a small space is inserted between words to make them more readable:

Use minimal spacing:

Specify the spacing:

Applications  (8)

Basic Applications  (4)

Summarize a webpage in a word cloud:

Summarize a piece of text:

Put selected words in the shape of the US map:

Create a word cloud of all artworks of Picasso:

Extract name, area, and an image corresponding to each artwork:

Create the word cloud and use images as tooltips:

Compute and visualize different identifications of an image:

Use probabilities as weights when forming the word cloud:

Word Selection  (1)

Create a word cloud of nouns longer than two characters:

Split the input:

Extract all nouns from a dictionary:

Select input strings that are nouns longer than two characters:

Language Analysis  (3)

Visualize the frequency of the characters in the built-in dictionary:

The first 50 trigrams in the English version of the Aeneid:

Word cloud of nouns in a dictionary weighted by their number of synonyms:

Select words that have at least one synonym:

Use the list of synonyms of each word as its tooltip:

Properties & Relations  (2)

By default, a single string is processed using TextWords and DeleteStopwords:

By default, the capitalization of words is preserved. With multiple occurrences, the first instance is used:

Use all uppercase characters:

Use all lowercase characters:

Possible Issues  (1)

By default, stopwords are deleted when a string is used as input:

Split the string beforehand to keep all the words:

Interactive Examples  (1)

Word cloud animation of country populations over about three centuries:

Neat Examples  (1)

Word cloud of an expression:

Introduced in 2015
 (10.1)
 |
Updated in 2016
 (11.0)
2017
 (11.2)