Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Animated Bubble Chart

  • To: mathgroup at smc.vnet.net
  • Subject: [mg100153] Re: Animated Bubble Chart
  • From: "Drago Ganic" <dganic at vodatel.net>
  • Date: Tue, 26 May 2009 05:11:39 -0400 (EDT)
  • References: <gv5dt0$ib8$1@smc.vnet.net>

Hi,
you should basically parametrize your data with a year parameter:

data[year_] := {#1, Log@#2, #3} & @@@
  Table[CountryData[c, {{p}, year}], {c, countries}, {p, properties}]

and then Animate/Manipulate the graph

Animate[
 Quiet[
  BubbleChart[
   data[year],
   ChartStyle -> 24,
   LabelingFunction -> labeler,
   FrameLabel -> {"PopulationGrowth", "Log GDP Per Capita"},
   PlotRange -> {{-0.02, 0.04}, {5, 12}},
   Prolog -> {Text[Style[year, FontSize -> Scaled[0.4], FontColor -> 
LightGray], Scaled[{1/2, 1/2}]]}]
  ],
 {year, 2000, 2006, 1}]


Unfortunately, you can not use the property "Poverty Fraction" because it 
does not have historical values, e.g. the function form:
    CountryData[c, {{"Poverty Fraction"}, year}]
does not work.

Use "PopulationGrowth" or something from the list:

{"AgriculturalValueAdded", "ConstructionValueAdded", "ExchangeRate", \
"ExpenditureFractions", "ExportValue", "FixedInvestment", "GDP", \
"GDPPerCapita", "GDPRealGrowth", "GDPSectorFractions", \
"GovernmentConsumption", "GrossInvestment", "HouseholdConsumption", \
"ImportValue", "IndustrialValueAdded", "InflationRate", \
"InventoryChange", "ManufacturingValueAdded", \
"MiscellaneousValueAdded", "NationalIncome", "Population", \
"PopulationGrowth", "PriceIndex", "TotalConsumption", \
"TradeValueAdded", "TransportationValueAdded", "ValueAdded"}

Best regards,
Drago

P.S.: Could somebody fix the aspect ratio problem of the bubles?

"Jon Rogers" <jroge at mac.com> wrote in message 
news:gv5dt0$ib8$1 at smc.vnet.net...
>I am looking to create an animated bubble chart similar to what Hans
> Rosling did at TED a few years ago. It seems like Mathematica's
> Manipulate function is a perfect tool for doing this. Can anyone
> suggest some ideas on how to approach this? I am a newbie user and
> have gotten stuck.
>
> I am pulling in data using the CountryData function and one of the
> examples from the built-in documentation. Here is the code from the
> online documentation:
>
>
> countries = CountryData["Europe"];
>
> properties = {"PovertyFraction", "GDPPerCapita", "Population"};
>
> data = {#1, Log@#2, #3} & @@@
>    Table[CountryData[c, p], {c, countries}, {p, properties}];
>
> labeler[v_, {r_, c_}, ___] :=
>  Placed[Grid[{{Style[countries[[c]], Bold, 12], SpanFromLeft},
> {"Poverty",
>      Row[{Round[100 v[[1]]], "%"}]}, {"GDP Per Capita",
>      Row[{"$", Round[Exp[v[[2]]]]}]}, {"Population",
>      Row[{NumberForm[v[[3]] 10^-6, {4, 2}], " million"}]}},
>    Alignment -> Left], Tooltip]
>
> BubbleChart[data, ChartStyle -> 24, LabelingFunction -> labeler,
>  FrameLabel -> {"Poverty Fraction", "Log GDP Per Capita"}]
>
>
> The chart is using poverty on the X-Axis, GDP Per Capita on the Y, and
> Population for the bubble size. I would like to animate the bubbles
> for a 10-year period, 1990-2000. Any pointers would be appreciated.
>
> Thanks,
>
> Jon
>
>
>
> PS: Here is a link to Hans' TED presentation:
>
> http://www.ted.com/index.php/talks/hans_rosling_shows_the_best_stats_you_ve_ever_seen.html
> 



  • Prev by Date: Re: list manipulation
  • Next by Date: using predefined expressions in functions [newbie question]
  • Previous by thread: Animated Bubble Chart
  • Next by thread: Re: Trouble with FullSimplify