{"id":10805,"date":"2019-06-14T09:00:09","date_gmt":"2019-06-14T13:00:09","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=10805"},"modified":"2019-06-13T22:26:56","modified_gmt":"2019-06-14T02:26:56","slug":"alluvial-flow-diagram","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2019\/06\/14\/alluvial-flow-diagram\/","title":{"rendered":"Alluvial flow diagram"},"content":{"rendered":"\r\n\r\n<div class=\"content\"><p><a href=\"http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/869871\">Jiro<\/a>&#8216;s Pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/66746\">Alluvial flow diagram<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/1297181\">Alexander Carmeli<\/a>.<\/p><p>I give credit to <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/642467\">Yair<\/a> for bringing this entry to my attention. He said, &#8220;Such diagrams can be very useful to analyze large categorized timeseries data sets (website traffic, for example).&#8221; I was not aware of such visualization, but <a href=\"https:\/\/en.wikipedia.org\/wiki\/Alluvial_diagram\">alluvial diagrams<\/a> let you visualize change in network structure over time. But the same diagram can be used to visualize how a group of categories map to a different set of categories. Alexander includes an interesting example with his entry. I&#8217;ll include it here.<\/p><p>Let&#8217;s say that there are four video gamers&#8230;<\/p><pre class=\"codeinput\">left_labels = {<span class=\"string\">'Arun'<\/span>, <span class=\"string\">'Kaushik'<\/span>, <span class=\"string\">'Federico'<\/span>, <span class=\"string\">'Dave'<\/span>};\r\n<\/pre><p>&#8230;who play video games during all parts of the day.<\/p><pre class=\"codeinput\">right_labels = {<span class=\"string\">'Morning'<\/span>, <span class=\"string\">'Afternoon'<\/span>, <span class=\"string\">'Evening'<\/span>};\r\n<\/pre><p>We create a matrix of players (row) and part-of-day (column). Each number indicates how many hours a player plays during a particular part of day. For example, in the data below, player 2 plays 3 hours in the morning, 1 hour in the evening, and does not play in the afternoon.<\/p><pre class=\"codeinput\">data = [ 2   2   2;\r\n         3   0   1;\r\n         1   2   3;\r\n         4   3   4];\r\n<\/pre><p>Show how the time played is distributed among gamers and parts of day.<\/p><pre class=\"codeinput\">alluvialflow(data, left_labels, right_labels, <span class=\"string\">'Video gaming hours of four gamers'<\/span>);\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_alluvialflow\/potw_alluvialflow_01.png\" alt=\"\"> <p>Visually, you can immediately tell that Dave plays the most, and players play the least in the afternoon.<\/p><p>Pretty cool, huh?<\/p><p><b>Community Advisors<\/b><\/p><p>One other thing, I&#8217;d like to introduce a new page in MATLAB Central, the <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/community-advisors.html\">Community Advisors<\/a>. If you didn&#8217;t know already, <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/642467\">Yair<\/a> is one of our most active community users, and he is also a part of the Community Advisory Board. As you can read from the page, the board members consist of our most active members of the MATLAB Central community, and they help us make MATLAB Central an even better place for our users. This month, I had the honor to meet a few of them in person in Boston. We&#8217;re so grateful to have such strong advisors!<\/p><p><b>Comments<\/b><\/p><p>Give the alluvial flow diagram a try and let us know what you think <a href=\"http:\/\/blogs.mathworks.com\/pick\/?p=10805#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/66746#comment\">comment<\/a> for Alexander.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_89257ab4465745ef92ad5f431b82556f() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='89257ab4465745ef92ad5f431b82556f ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 89257ab4465745ef92ad5f431b82556f';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        copyright = 'Copyright 2019 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n\r\n        d.title = title + ' (MATLAB code)';\r\n        d.close();\r\n    }   \r\n     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_89257ab4465745ef92ad5f431b82556f()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2019a<br><\/p><p class=\"footer\"><br>\r\n      Published with MATLAB&reg; R2019a<br><\/p><\/div><!--\r\n89257ab4465745ef92ad5f431b82556f ##### SOURCE BEGIN #####\r\n%%\r\n% <http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/869871 Jiro>'s\r\n% Pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/66746 Alluvial flow\r\n% diagram> by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/1297181\r\n% Alexander Carmeli>.\r\n%\r\n% I give credit to\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/642467 Yair> for\r\n% bringing this entry to my attention. He said, \"Such diagrams can be very\r\n% useful to analyze large categorized timeseries data sets (website\r\n% traffic, for example).\" I was not aware of such visualization, but\r\n% <https:\/\/en.wikipedia.org\/wiki\/Alluvial_diagram alluvial diagrams> let\r\n% you visualize change in network structure over time. But the same diagram\r\n% can be used to visualize how a group of categories map to a different set\r\n% of categories. Alexander includes an interesting example with his entry.\r\n% I'll include it here.\r\n%\r\n% Let's say that there are four video gamers...\r\nleft_labels = {'Arun', 'Kaushik', 'Federico', 'Dave'};\r\n\r\n%%\r\n% ...who play video games during all parts of the day.\r\nright_labels = {'Morning', 'Afternoon', 'Evening'};\r\n\r\n%%\r\n% We create a matrix of players (row) and part-of-day (column). Each number\r\n% indicates how many hours a player plays during a particular part of day.\r\n% For example, in the data below, player 2 plays 3 hours in the morning, 1\r\n% hour in the evening, and does not play in the afternoon.\r\ndata = [ 2   2   2;\r\n         3   0   1;\r\n         1   2   3;\r\n         4   3   4];\r\n\r\n%%\r\n% Show how the time played is distributed among gamers and parts of day.\r\nalluvialflow(data, left_labels, right_labels, 'Video gaming hours of four gamers');\r\n\r\n%%\r\n% Visually, you can immediately tell that Dave plays the most, and players\r\n% play the least in the afternoon.\r\n%\r\n% Pretty cool, huh?\r\n%\r\n% *Community Advisors*\r\n%\r\n% One other thing, I'd like to introduce a new page in MATLAB Central, the\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/community-advisors.html\r\n% Community Advisors>. If you didn't know already,\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/642467 Yair> is\r\n% one of our most active community users, and he is also a part of the\r\n% Community Advisory Board. As you can read from the page, the board\r\n% members consist of our most active members of the MATLAB Central\r\n% community, and they help us make MATLAB Central an even better place for\r\n% our users. This month, I had the honor to meet a few of them in person in\r\n% Boston. We're so grateful to have such strong advisors!\r\n%\r\n% *Comments*\r\n%\r\n% Give the alluvial flow diagram a try and let us know what you think\r\n% <http:\/\/blogs.mathworks.com\/pick\/?p=10805#respond here> or leave a\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/66746#comment\r\n% comment> for Alexander.\r\n\r\n##### SOURCE END ##### 89257ab4465745ef92ad5f431b82556f\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_alluvialflow\/potw_alluvialflow_01.png\" onError=\"this.style.display ='none';\" \/><\/div><p>\r\n\r\nJiro&#8216;s Pick this week is Alluvial flow diagram by Alexander Carmeli.I give credit to Yair for bringing this entry to my attention. He said, &#8220;Such diagrams can be very useful to&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2019\/06\/14\/alluvial-flow-diagram\/\">read more >><\/a><\/p>","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/10805"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=10805"}],"version-history":[{"count":5,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/10805\/revisions"}],"predecessor-version":[{"id":10815,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/10805\/revisions\/10815"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=10805"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=10805"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=10805"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}