Wolfram Language

Open live version

Plot Population Growth

See how a countrys population has grown.


code

DateListPlot[CountryData["USA", {{"Population"}, {1970, 2000}}]]

Make a URL that plots the population growth of several countries.

PlotPopulationGrowth[countries_List, begin_: 1970] := DateListPlot[ CountryData[#, {{"Population"}, {begin, Today["Year"]}}] & /@ countries, PlotLegends -> CommonName /@ countries, PlotLabel -> "Population Growth" ]
CloudDeploy[APIFunction[{ "countries" -> Interpreter[DelimitedSequence["ComputedCountry"]], "begin" -> {"Integer", 1970}}, Pane[PlotPopulationGrowth [#countries, #begin], ImageMargins -> 50] &, "PNG"], Permissions -> "Public"]

how it works

This example was live-coded at the Wolfram Research booth at SXSW, March 9, 2014.

How did the US population grow from 1970 to 2000?

DateListPlot[CountryData["USA", {{"Population"}, {1970, 2000}}]]

You can make a function that plots the population growth of several countries at once:

PlotPopulationGrowth[countries_List, begin_: 1970] := DateListPlot[ CountryData[#, {{"Population"}, {begin, Today["Year"]}}] & /@ countries, PlotLegends -> CommonName /@ countries, PlotLabel -> "Population Growth" ]
PlotPopulationGrowth[{\!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{WolframAlphaClient`Private`query$$ = "germany", WolframAlphaClient`Private`boxes$$ = TemplateBox[{"\"Germany\"", RowBox[{"Entity", "[", RowBox[{"\"Country\"", ",", "\"Germany\""}], "]"}], "\"Entity[\\\"Country\\\", \\\"Germany\\\"]\"", "\"country\""}, "Entity"], WolframAlphaClient`Private`allassumptions$$ = {}, WolframAlphaClient`Private`assumptions$$ = {}, WolframAlphaClient`Private`open$$ = {1, 2}}, DynamicBox[ToBoxes[ AlphaIntegration`LinguisticAssistantBoxes["", 1, Dynamic[WolframAlphaClient`Private`query$$], Dynamic[WolframAlphaClient`Private`boxes$$], Dynamic[WolframAlphaClient`Private`allassumptions$$], Dynamic[WolframAlphaClient`Private`assumptions$$], Dynamic[WolframAlphaClient`Private`open$$]], StandardForm], ImageSizeCache->{142., {7., 15.}}, TrackedSymbols:>{ WolframAlphaClient`Private`query$$, WolframAlphaClient`Private`boxes$$, WolframAlphaClient`Private`allassumptions$$, WolframAlphaClient`Private`assumptions$$, WolframAlphaClient`Private`open$$}], DynamicModuleValues:>{}, UndoTrackedVariables:>{WolframAlphaClient`Private`open$$}], BaseStyle->{"Deploy"}, DeleteWithContents->True, Editable->False, SelectWithContents->True]\), \!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{WolframAlphaClient`Private`query$$ = "france", WolframAlphaClient`Private`boxes$$ = TemplateBox[{"\"France\"", RowBox[{"Entity", "[", RowBox[{"\"Country\"", ",", "\"France\""}], "]"}], "\"Entity[\\\"Country\\\", \\\"France\\\"]\"", "\"country\""}, "Entity"], WolframAlphaClient`Private`allassumptions$$ = {{ "type" -> "Clash", "word" -> "france", "template" -> "Assuming \"${word}\" is ${desc1}. Use as \ ${desc2} instead", "count" -> "2", "Values" -> {{ "name" -> "Country", "desc" -> "a country", "input" -> "*C.france-_*Country-"}, { "name" -> "GivenName", "desc" -> "a given name", "input" -> "*C.france-_*GivenName-"}}}}, WolframAlphaClient`Private`assumptions$$ = {}, WolframAlphaClient`Private`open$$ = {1, 2}}, DynamicBox[ToBoxes[ AlphaIntegration`LinguisticAssistantBoxes["", 1, Dynamic[WolframAlphaClient`Private`query$$], Dynamic[WolframAlphaClient`Private`boxes$$], Dynamic[WolframAlphaClient`Private`allassumptions$$], Dynamic[WolframAlphaClient`Private`assumptions$$], Dynamic[WolframAlphaClient`Private`open$$]], StandardForm], ImageSizeCache->{153., {7., 15.}}, TrackedSymbols:>{ WolframAlphaClient`Private`query$$, WolframAlphaClient`Private`boxes$$, WolframAlphaClient`Private`allassumptions$$, WolframAlphaClient`Private`assumptions$$, WolframAlphaClient`Private`open$$}], DynamicModuleValues:>{}, UndoTrackedVariables:>{WolframAlphaClient`Private`open$$}], BaseStyle->{"Deploy"}, DeleteWithContents->True, Editable->False, SelectWithContents->True]\), \!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{WolframAlphaClient`Private`query$$ = "united kingdom", WolframAlphaClient`Private`boxes$$ = TemplateBox[{"\"United Kingdom\"", RowBox[{"Entity", "[", RowBox[{"\"Country\"", ",", "\"UnitedKingdom\""}], "]"}], "\"Entity[\\\"Country\\\", \\\"UnitedKingdom\\\"]\"", "\"country\""}, "Entity"], WolframAlphaClient`Private`allassumptions$$ = {{ "type" -> "Clash", "word" -> "united kingdom", "template" -> "Assuming \"${word}\" is ${desc1}. Use as \ ${desc2} instead", "count" -> "2", "Values" -> {{ "name" -> "Country", "desc" -> "a country", "input" -> "*C.united+kingdom-_*Country-"}, { "name" -> "MusicWork", "desc" -> "a music work", "input" -> "*C.united+kingdom-_*MusicWork-"}}}}, WolframAlphaClient`Private`assumptions$$ = {}, WolframAlphaClient`Private`open$$ = {1, 2}}, DynamicBox[ToBoxes[ AlphaIntegration`LinguisticAssistantBoxes["", 1, Dynamic[WolframAlphaClient`Private`query$$], Dynamic[WolframAlphaClient`Private`boxes$$], Dynamic[WolframAlphaClient`Private`allassumptions$$], Dynamic[WolframAlphaClient`Private`assumptions$$], Dynamic[WolframAlphaClient`Private`open$$]], StandardForm], ImageSizeCache->{210., {7., 15.}}, TrackedSymbols:>{ WolframAlphaClient`Private`query$$, WolframAlphaClient`Private`boxes$$, WolframAlphaClient`Private`allassumptions$$, WolframAlphaClient`Private`assumptions$$, WolframAlphaClient`Private`open$$}], DynamicModuleValues:>{}, UndoTrackedVariables:>{WolframAlphaClient`Private`open$$}], BaseStyle->{"Deploy"}, DeleteWithContents->True, Editable->False, SelectWithContents->True]\)}]

Deploy that function to the cloud to make a URL whose query string specifies the countries to plot:

CloudDeploy[APIFunction[{ "countries" -> Interpreter[DelimitedSequence["ComputedCountry"]], "begin" -> {"Integer", 1970}}, Pane[PlotPopulationGrowth [#countries, #begin], ImageMargins -> 50] &, "PNG"], Permissions -> "Public"]

This URL gives you a plot of the population growth in Germany, France, and England since 1980:

Hyperlink["https://www.wolframcloud.com/objects/42d6e992-015e-4ab8-\ bb1b-479ee49f33c1?countries=germany,france,england&begin=1980"]