Wolfram言語

新しい可視化領域

重み付きデータに対してワードクラウドを使う

それぞれの国に人口で重みを付けるデータを生成する.

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}];

それぞれの国に対して同じ色を常に使用する色関数を構築する.

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

国を表す文字の大きさに人口で重みを付けた,時間の経過に伴う一連のワードクラウドを作成する.

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]=

関連する例

de en es fr ko pt-br ru zh