1
$\begingroup$

I am working on some animations of geographic entities. I have a Manipulate with GeoListPlot as below:

cty = CountryData[];
someIndicator = BlockRandom[SeedRandom[123]; RandomReal[1, Length@cty]];
list = Transpose@{cty, someIndicator};

Manipulate[GeoListPlot[Select[list, #[[2]] <= t &][[All, 1]],GeoRange -> "World", GeoProjection -> "CylindricalEqualArea"],
 {t, 0, 1, Appearance -> "Labeled"}]

As you can see, when you slide the button for t of the Manipulate, the number of highlighted countries in the world map increase.

The sliding is smooth when t is small. However, when the value of t increase, the sliding become very slow (even after downloading all the countries' data) during the sliding. How can I make the sliding smoother and faster?

Many thanks!

$\endgroup$
1
$\begingroup$

Your problem is that the Manipulate environment is trying to update the map even while you slide the controller (prevented by AutoAction->False), and for arbitrary precision values for t (prevented by quantizing values to 0.01):

Manipulate[
 GeoListPlot[Select[list, #[[2]] <= t &][[All, 1]], 
  GeoRange -> "World", GeoProjection -> "CylindricalEqualArea"], {t, 
  0, 1, .01, Appearance -> "Labeled", AutoAction -> False}]
$\endgroup$
  • $\begingroup$ Thanks. The sliding is smoother than before. Is it possible to forsake some memory but memorizing something (say part of the list, so that the Select don't need to do all the job again) to make the sliding even smoother when t is large? $\endgroup$ – H42 Jul 5 '18 at 18:58
  • $\begingroup$ I would recommend sticking with a discrete variable whenever the task allows it. If you have lots and lots of memory and time to precompute your results, then you can store the maps for each possible value of $t$ (or, preferably, an Integer index) and merely select and "play" a map through Manipulate choice. That's the extreme case. $\endgroup$ – David G. Stork Jul 5 '18 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.