Stata without having to learn any other software Robert Grant Senior Research Fellow St Georges University of London amp Kingston University The objective I have seen some cool graphs made into videos like Hans ID: 209471
Download Presentation The PPT/PDF document "Producing animated graphs from" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Producing animated graphs from Stata without having to learn any other software
Robert GrantSenior Research FellowSt George’s, University of London& Kingston UniversitySlide2
The objectiveI have seen some cool graphs made into videos like Hans
Rosling’s 200 Countries
and I thought “I want to do that!”Stata Users’ Group London 2012
2
www.animatedgraphs.co.ukSlide3
The objectiveI analyse data all day longI am (if I say so myself) pretty good using stats software
but I know nothing about video softwareand in fact I don't have the time/money/energy to learnStata Users’ Group London 20123
www.animatedgraphs.co.ukSlide4
The objectiveI analyse data all day longI am (if I say so myself) pretty good using stats software
but I know nothing about video softwareand in fact I don't have the time/money/energy to learnI want to make animations from inside Stata I want the process to be simple but totally flexible so I am not restricted in the look of my animations and the effects I can build into them.
Stata Users’ Group London 20124
www.animatedgraphs.co.ukSlide5
Stop frame animationMovies are made up of a series of still images
If you can control the images, you can make anything happenYou already know how to control Stata graphsStata Users’ Group London 2012
5www.animatedgraphs.co.ukSlide6
Stop frame animationFor Ray
Harryhausen or Nick Park and their talented animators, this was (and still is) very hard workStata Users’ Group London 20126
www.animatedgraphs.co.uk
But you have
Stata
programming at your disposal to make lots of images quicklySlide7
The basic do-fileSet up macros with the graph optionsLoop over the number of frames
Advance / interpolate the data one stepDraw the graphExport the graphUse -winexec- to call the free open source software FFMPEG and make the images into a video file
FFMPEG runs “behind the scenes” (no GUI)Stata Users’ Group London 2012
7
www.animatedgraphs.co.ukSlide8
Example 1: Line filling from left to right
Stata Users’ Group London 20128www.animatedgraphs.co.ukSlide9
Example 1: Line filling from left to rightStata Users’ Group London 2012
9www.animatedgraphs.co.ukSlide10
Example 2: Line scrolling from left to right
Stata Users’ Group London 201210www.animatedgraphs.co.ukSlide11
Example 3: Interpolated scatterplot
Stata Users’ Group London 201211www.animatedgraphs.co.ukSlide12
Example 4: Trails made with phantom data
Stata Users’ Group London 201212www.animatedgraphs.co.ukSlide13
Use or abuse?It is possible to draw the eye to one aspect of the animation through your aesthetic choices“My voice is a powerful gift. It can be used for good or it can be used for evil.” - Barry White
Some points might move faster than others; should data start and stop moving together?Be careful to control axes so they don’t creepColour, light, emphasis, soundStata Users’ Group London 2012
www.animatedgraphs.co.uk13Slide14
Example 5: Hans recreated
Stata Users’ Group London 201214www.animatedgraphs.co.ukSlide15
Stata strengths and weaknesses
The ease and flexibility of macrosHaving a direct link to the operating systemPowerful graphicsHaving to display each graph slows it downHaving to split into multiple
-graph twoway- commands to change size and colour
Stata Users’ Group London 2012
www.animatedgraphs.co.uk
15Slide16
www.animatedgraphs.co.ukAll these examples, and some moreAll the do-filesTips on achieving particular aesthetics
User contributionsExpanding into R, SPSS, and maybe Excel VBAConsultancy: I can do bespoke graphs but would rather teach you how to catch the fishStata Users’ Group London 2012www.animatedgraphs.co.uk
16