{"id":8170,"date":"2021-12-10T17:47:31","date_gmt":"2021-12-10T22:47:31","guid":{"rendered":"https:\/\/blogs.mathworks.com\/community\/?p=8170"},"modified":"2021-12-13T11:44:17","modified_gmt":"2021-12-13T16:44:17","slug":"mini-hack-contest-analysis","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/community\/2021\/12\/10\/mini-hack-contest-analysis\/","title":{"rendered":"Mini Hack Contest Analysis"},"content":{"rendered":"<div class=\"rtcContent\">\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #000000; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><em>Today we have a guest post from Dave Bulkin. Dave is a developer on the MATLAB Graphics and Charting Team. Dave used to be a neuroscientist, but he loved MATLAB data visualization so much he decided to join MathWorks and work full time on charts.<\/em><\/div>\n<h2>Mini Hack Contest Analysis<\/h2>\n<p><em>by Dave Bulkin<\/em><\/p>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #000000; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">First of all, thanks to both the organizers and the contributors to <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/contests\/20th-anniversary-matlab-minihack.html\">MATLAB Mini Hack<\/a>. In addition to all the fun it was really inspiring to us on the Graphics Team! As Chen wrote in his summary, I made more than a few charts to look at some of the data about the contest. Chen showed a couple of these charts, but Ned was kind enough to let me share a few more on his blog, along with some code.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #000000; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">The two that Chen shared in his summary included a <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/swarmchart.html\">swarmchart<\/a> showing the distribution of the number of characters in each entry, a bar chart showing the most popular functions (and an inset showing the specific ways <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/axis.html\">axis<\/a> was called). Swarm charts are relatively new \u2013 they\u2019re a kind of <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/scatter.html\">scatter<\/a> chart, but with points jittered based on an estimate of the kernel density.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #000000; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 699px; height: 438px;\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/blogpostforned_1.png\" alt=\"\" width=\"878\" height=\"501\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #000000; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">An interesting similar analysis was about how many characters were used in comments. To make a 'broken' y-axis here, I used a trick with <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/tiledlayout.html\">tiledlayout<\/a> and <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/nexttile.html\">nexttile<\/a>. This lets you see the distribution while keeping a y-axis that includes the large number of entries with 0 (or very few) characters in comments.<\/div>\n<div class=\"preformatted-matlab\" style=\"margin: 10px 3px 10px 55px; padding: 10px 10px 10px 5px;\">\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\">t=tiledlayout(4, 1, <span style=\"color: #a709f5;\">'TileSpacing'<\/span>, <span style=\"color: #a709f5;\">'compact'<\/span>);<\/span><\/div>\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\">nexttile(t);<\/span><\/div>\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% histogram code here<\/span><\/span><\/div>\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\">ylim([1000 1500]);<\/span><\/div>\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\">xticklabels(<span style=\"color: #a709f5;\">\"\"<\/span>)<\/span><\/div>\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\">nexttile(t, [3 1])<\/span><\/div>\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% same histogram code here <\/span><\/span><\/div>\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\">ylim([0 100])<\/span><\/div>\n<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #000000; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 537px; height: 422px;\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/blogpostforned_2.png\" alt=\"\" width=\"537\" height=\"422\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #000000; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Next, I wondered what variable names were most popular (unsurprisingly single character variable names dominated the entries). Here I used one of our newest charts: <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/bubblecloud.html\">bubblecloud<\/a>, which gives a cool view of so called \u2018Parts-to-whole\u2019 data. These charts are fun and can give a sense of the biggest values as well as just how many categories there are in a dataset. The <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/matlab.graphics.chart.primitive.histogram.html\">histogram<\/a> chart at the top shows the most common variables, which is helpful for tying this new-style chart to something more familiar. I labeled the bars at the top with this trick:<\/div>\n<div class=\"preformatted-matlab\" style=\"margin: 10px 3px 10px 55px; padding: 10px 10px 10px 5px;\">\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\">h = histogram(varnames); <span style=\"color: #008013;\">% Be sure to use reordercats to get varnames in the right order<\/span><\/span><\/div>\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\">xt = xticks; <span style=\"color: #008013;\">% Because this is a categorical axis, there's a tick for each label<\/span><\/span><\/div>\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\">text(xt(1:30), h.Values(1:30), string(xt(1:30)), <span style=\"color: #0e00ff;\">...<\/span><\/span><\/div>\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\"> <span style=\"color: #a709f5;\">'HorizontalAlignment'<\/span>, <span style=\"color: #a709f5;\">'center'<\/span>, <span style=\"color: #a709f5;\">'VerticalAlignment'<\/span>, <span style=\"color: #a709f5;\">'bottom'<\/span>)<\/span><\/div>\n<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #000000; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #000000; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 541px; height: 501px;\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/blogpostforned_3.png\" alt=\"\" width=\"541\" height=\"501\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #000000; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">I also wondered when people submitted their entries and when they voted. While MATLAB is most popular in general on weekdays, some of us hypothesized that we\u2019d see more entries on weekends when people weren\u2019t busy at work. But that wasn\u2019t the case, weekdays were more popular for submitting entries and Friday was the most popular day for voting. Did you know that the <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/matlab.graphics.chart.primitive.histogram.html\">histogram<\/a> function lets you directly choose time units for bins when working with <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/datetime.html\">datetime<\/a> data?<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #000000; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 700px; height: 806px;\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/blogpostforned_4.png\" alt=\"\" width=\"848\" height=\"921\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #000000; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #000000; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Finally, I made some <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/boxchart.html\">boxchart<\/a>s and a <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/bubblechart.html\">bubblechart<\/a> to look at who was submitting entries and who was voting. I wasn\u2019t surprised to see some of our community MVPs really got involved and were espescially successful, and I was glad to see so much participation among MathWorkers. Shout out to Chen for everything he did to organize the contest, and for voting 912 times\u2026I had to cut down our Y limits because he was such an outlier!<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #000000; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Here's how I placed my legend in the aligned to the layout:<\/div>\n<div class=\"preformatted-matlab\" style=\"margin: 10px 3px 10px 55px; padding: 10px 10px 10px 5px;\">\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\">t = tiledlayout(3,2);<\/span><\/div>\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\">nexttile<\/span><\/div>\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% boxchart code here<\/span><\/span><\/div>\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\">leg = legend;<\/span><\/div>\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\">leg.Layout.Tile = <span style=\"color: #a709f5;\">'North'<\/span>;<\/span><\/div>\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% other plots here<\/span><\/span><\/div>\n<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #000000; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 700px; height: 799px;\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/blogpostforned_5.png\" alt=\"\" width=\"822\" height=\"913\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #000000; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #000000; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/blogpostforned_1.png\" onError=\"this.style.display ='none';\" \/><\/div>\n<p>\nToday we have a guest post from Dave Bulkin. Dave is a developer on the MATLAB Graphics and Charting Team. Dave used to be a neuroscientist, but he loved MATLAB data visualization so much he decided... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/community\/2021\/12\/10\/mini-hack-contest-analysis\/\">read more >><\/a><\/p>\n","protected":false},"author":69,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/8170"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/users\/69"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/comments?post=8170"}],"version-history":[{"count":4,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/8170\/revisions"}],"predecessor-version":[{"id":8182,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/8170\/revisions\/8182"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/media?parent=8170"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/categories?post=8170"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/tags?post=8170"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}