{"id":11743,"date":"2020-09-27T09:58:44","date_gmt":"2020-09-27T13:58:44","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=11743"},"modified":"2020-09-27T09:58:44","modified_gmt":"2020-09-27T13:58:44","slug":"r2020b-swarmchart","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2020\/09\/27\/r2020b-swarmchart\/","title":{"rendered":"R2020b: swarmchart"},"content":{"rendered":"<div class=\"content\"><p><a href=\"http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/869871\">Jiro<\/a>'s Pick this week is <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/swarmchart.html\"><tt>swarmchart<\/tt><\/a>, a new visualization function in R2020b.<\/p><p>Following Sean's <a href=\"https:\/\/blogs.mathworks.com\/pick\/2020\/09\/18\/r2020b\/\">post<\/a> from last week, I'd like to highlight a new function from <a href=\"https:\/\/www.mathworks.com\/products\/new_products\/latest_features.html\">the newest release of MATLAB<\/a>.<\/p><p>Many, many years ago, I <a href=\"https:\/\/blogs.mathworks.com\/pick\/2012\/09\/07\/beeswarm-plot\/\">Picked<\/a> a File Exchange entry called <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/37105-plot-spread-points-beeswarm-plot\">beeswarm plot<\/a>. It's a vizualization that lets you see the distribution of the data along a dimension.<\/p><pre class=\"codeinput\">data = {randn(1, 25), randn(1, 100) + 1, randn(1, 300) - 0.5};\r\nplotSpread(data, <span class=\"keyword\">...<\/span>\r\n    <span class=\"string\">'xNames'<\/span>, {<span class=\"string\">'one'<\/span>, <span class=\"string\">'two'<\/span>, <span class=\"string\">'three'<\/span>}, <span class=\"keyword\">...<\/span>\r\n    <span class=\"string\">'distributionMarkers'<\/span>, {<span class=\"string\">'o'<\/span>, <span class=\"string\">'+'<\/span>, <span class=\"string\">'.'<\/span>});\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_swarmchart\/potw_swarmchart_01.png\" alt=\"\"> <p>You can also see similar type of plots by searching for <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange?q=violin+plot\">\"violin plot\"<\/a>.<\/p><p>In R2020b, you can now create this type of visualization with the new function <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/swarmchart.html\"><tt>swarmchart<\/tt><\/a>.<\/p><pre class=\"codeinput\">data = [data{:}];\r\nx = categorical([ones(1,25) 2*ones(1,100) 3*ones(1,300)],[1 2 3],[<span class=\"string\">\"one\"<\/span> <span class=\"string\">\"two\"<\/span> <span class=\"string\">\"three\"<\/span>]);\r\n\r\nclf\r\nswarmchart(x,data)\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_swarmchart\/potw_swarmchart_02.png\" alt=\"\"> <p>If you are on an older release of MATLAB, you can make use of the entries on File Exchange, but I recommend you upgrade to the newest release to take advantange of the plethora of <a href=\"https:\/\/www.mathworks.com\/products\/new_products\/latest_features.html\">new features<\/a> that come with it.<\/p><p><b>Comments<\/b><\/p><p>Give it a try and let us know what you think <a href=\"http:\/\/blogs.mathworks.com\/pick\/?p=11743#respond\">here<\/a>.<\/p><br><p class=\"footer\"><br>\r\n      Published with MATLAB&reg; R2020b<br><\/p><\/div><!--\r\n9bcd561ecc3f474891ebe319af185945 ##### 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\/help\/matlab\/ref\/swarmchart.html |swarmchart|>,\r\n% a new visualization function in R2020b.\r\n%\r\n% Following Sean's <https:\/\/blogs.mathworks.com\/pick\/2020\/09\/18\/r2020b\/\r\n% post> from last week, I'd like to highlight a new function from\r\n% <https:\/\/www.mathworks.com\/products\/new_products\/latest_features.html the\r\n% newest release of MATLAB>. \r\n%\r\n% Many, many years ago, I\r\n% <https:\/\/blogs.mathworks.com\/pick\/2012\/09\/07\/beeswarm-plot\/ Picked> a\r\n% File Exchange entry called\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/37105-plot-spread-points-beeswarm-plot\r\n% beeswarm plot>. It's a vizualization that lets you see the distribution\r\n% of the data along a dimension. \r\n\r\ndata = {randn(1, 25), randn(1, 100) + 1, randn(1, 300) - 0.5};\r\nplotSpread(data, ...\r\n    'xNames', {'one', 'two', 'three'}, ...\r\n    'distributionMarkers', {'o', '+', '.'});\r\n\r\n%%\r\n% You can also see similar type of plots by searching for\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange?q=violin+plot\r\n% \"violin plot\">.\r\n%\r\n% In R2020b, you can now create this type of visualization with the new\r\n% function <https:\/\/www.mathworks.com\/help\/matlab\/ref\/swarmchart.html\r\n% |swarmchart|>.\r\n\r\ndata = [data{:}];\r\nx = categorical([ones(1,25) 2*ones(1,100) 3*ones(1,300)],[1 2 3],[\"one\" \"two\" \"three\"]);\r\n\r\nclf\r\nswarmchart(x,data)\r\n\r\n%%\r\n% If you are on an older release of MATLAB, you can make use of the entries\r\n% on File Exchange, but I recommend you upgrade to the newest release to\r\n% take advantange of the plethora of\r\n% <https:\/\/www.mathworks.com\/products\/new_products\/latest_features.html new\r\n% features> that come with it.\r\n%\r\n% *Comments*\r\n%\r\n% Give it a try and let us know what you think\r\n% <http:\/\/blogs.mathworks.com\/pick\/?p=11743#respond here>.\r\n\r\n##### SOURCE END ##### 9bcd561ecc3f474891ebe319af185945\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_swarmchart\/potw_swarmchart_01.png\" onError=\"this.style.display ='none';\" \/><\/div><p>Jiro's Pick this week is swarmchart, a new visualization function in R2020b.Following Sean's post from last week, I'd like to highlight a new function from the newest release of MATLAB.Many, many... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2020\/09\/27\/r2020b-swarmchart\/\">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\/11743"}],"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=11743"}],"version-history":[{"count":3,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/11743\/revisions"}],"predecessor-version":[{"id":11749,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/11743\/revisions\/11749"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=11743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=11743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=11743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}