到国家统计局下载历年(1993-2019年)各省的GDP数据,整理成如下形式。
这里所用的函数,来自GitHub中的一个项目,链接如下https://github.com/minoue-xx/BarChartRaceAnimation。
自编主程序代码如下
data = csvread("各省年度GDP数据.csv",1,1);%导入数据
data = data';
names=["北京市","天津市","河北省","山西省","内蒙古","辽宁省","吉林省","黑龙江省",...
"上海市","江苏省","浙江省","安徽省","福建省","江西省","山东省","河南省","湖北省",...
"湖南省","广东省","广西","海南省","重庆市","四川省","贵州省","云南省",...
"西藏","陕西省","甘肃省","青海省","宁夏","新疆"];
years = 1993:2019;
barChartRace(data,"IsInteger",false,"LabelNames",names,"Time",years,...
"XlabelName","亿元","GenerateGIF",true);
所用到的函数如下
barChartRace.m,mustBeNumericTableTimetable.m,mustBeTimeInput.m,mustBeVariableLabels.m,setDefaultLabels.m,setDefaultTime.m
上述函数都可以在https://github.com/minoue-xx/BarChartRaceAnimation这个上面,直接下载下来就可以用,这里不再引入。
最终结果如下:
生成的动画如下: