Racing bar charts
Jiro‘s Pick this week is barChartRace by Eiji Konaka.
This an example of a nice outcome that spawned from a community discussion. It all started with this tweet.
縺薙≧縺��≧縺ョ繧呈焔霆ス縺ォ縺、縺上l繧 #MATLAB @MATLAB_jp 縺ョ髢「謨ー縺ィ縺九≠縺」縺溘j縺吶k縺ョ縺九↑��・��・��・縺サ縺励>縺ェ��・��・��・�� https://t.co/gOuBm5HwCn
— konakalab (蟆丈クュ遐皮ゥカ螳、/蜷榊沁螟ァ) (@konakalab) January 20, 2020
Translation: “Is there a simple MATLAB function that could easily create this animation? I want it…”
I learned that this type of animation, where the bars switch places based on the order, is called Bar Chart Race.
My colleague, Michio, replied to the tweet saying that you can do some graphical updates with the barh function.
縺薙l��√→縺��≧髢「謨ー縺ッ谿句ソオ縺ェ縺後i遏・繧峨↑縺��s縺ァ縺吶′縲|arh 縺ョ繧ェ繝悶ず繧ァ繧ッ繝医r譖エ譁ー縺吶l縺ー繝サ繝サ縲https://t.co/DuhjIgv6I7
— michio inoue (@michio_MWJ) January 20, 2020
Michio created a sample, which he explained in a Japanese technical community site (in Japanese). This inspired Eiji to create his barChartRace, and he also wrote about it here (in Japanese).
So, let’s see this in action. I made some modifications to Eiji’s function to include an option to display the time stamp in the title, and to reverse the order of the bars. Here is an example of the FIFA World Rankings from 1993 to 2018. The rankings are based on the data from https://www.fifa.com/fifa-world-ranking/ranking-table/men/
load data y time countries Opt.xTickLabelStrs = countries; Opt.outFileName='barchartrace_outFile.gif'; Opt.xLabelStr='Ranking'; Opt.yLabelStr='Country'; Opt.titleStr='FIFA World Ranking'; Opt.faceColor=[0,0,1]; Opt.time = time; Opt.yDir = 'reverse'; barChartRace(y, Opt)
It was great to see the communication and collaboration that happened over social media. By the way, Michio went ahead and extended his version of the bar chart race to include a few other options. You can find it here.
Comments
Give it a try and let us know what you think here or leave a comment for Eiji.
- 类别:
- Picks
评论
要发表评论,请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。