Wolfram Language

New Visualization Domains

Use Word Clouds for Weighted Data

Create data that weights each country with its population.

In[1]:=
Click for copyable input
years = Range[1716, 2016, 100]; data = Table[ AssociationThread @@ Transpose[ Select[EntityValue[ CountryData[], {"Name", EntityProperty["Country", "Population", {"Date" -> DateObject[{year}]}]}], TrueQ[Last[#] > \!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query$$ = "0 people", Typeset`boxes$$ = TemplateBox[{"0", "\"people\"", "people", "\"People\""}, "Quantity", SyntaxForm -> Mod], Typeset`allassumptions$$ = {}, Typeset`assumptions$$ = {}, Typeset`open$$ = {1, 2}, Typeset`querystate$$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 1.326065`6.574109805988145, "Messages" -> {}}}, DynamicBox[ToBoxes[ AlphaIntegration`LinguisticAssistantBoxes["", 4, Automatic, Dynamic[Typeset`query$$], Dynamic[Typeset`boxes$$], Dynamic[Typeset`allassumptions$$], Dynamic[Typeset`assumptions$$], Dynamic[Typeset`open$$], Dynamic[Typeset`querystate$$]], StandardForm], ImageSizeCache->{101., {8., 16.}}, TrackedSymbols:>{ Typeset`query$$, Typeset`boxes$$, Typeset`allassumptions$$, Typeset`assumptions$$, Typeset`open$$, Typeset`querystate$$}], DynamicModuleValues:>{}, UndoTrackedVariables:>{Typeset`open$$}], BaseStyle->{"Deploy"}, DeleteWithContents->True, Editable->False, SelectWithContents->True]\)] &]], {year, years}];

Construct a color function that always uses the same color for each country.

In[2]:=
Click for copyable input
cfun[weight_, string_] := cfun[_, string] = RandomChoice[ColorData[97, "ColorList"]]

Make a series of word clouds over time, where the size of the country is weighted by its population.

In[3]:=
Click for copyable input
Multicolumn[ MapThread[ WordCloud[#, PlotLabel -> Style[Framed[#2], 16, Background -> LightGray], ColorFunction -> cfun, ImageSize -> 300] &, {data, years}], 2, Appearance -> "Horizontal"]
Out[3]=

Related Examples

de es fr ja ko pt-br ru zh