{"id":11485,"date":"2020-04-27T08:58:40","date_gmt":"2020-04-27T12:58:40","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=11485"},"modified":"2020-04-27T09:01:49","modified_gmt":"2020-04-27T13:01:49","slug":"ridgeline-visualization","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2020\/04\/27\/ridgeline-visualization\/","title":{"rendered":"Ridgeline Visualization"},"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\/matlabcentral\/fileexchange\/75147\"><tt>joyPlot<\/tt><\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/8557334\">Santiago Benito<\/a>.<\/p><p>I must admit that I was simply drawn by the visualization, rather than the name of the function, as I was not familiar with the band or the music album. It was interesting to read the <a href=\"https:\/\/www.vice.com\/en_us\/article\/gvd9aj\/the-story-behind-joy-divisions-iconic-iunknown-pleasuresi-album-cover\">back story<\/a>.<\/p><p>The visualization is a stacked plot with overlap, resembling a ridgeline. Here is an example from the sample code that Santiago includes with his entry.<\/p><pre class=\"codeinput\">data = readmatrix(websave(<span class=\"string\">'pulsar.csv'<\/span>,[<span class=\"string\">'https:\/\/gist.githubusercontent.com\/borgar\/'<\/span>,<span class=\"keyword\">...<\/span>\r\n    <span class=\"string\">'31c1e476b8e92a11d7e9\/raw\/0fae97dab6830ecee185a63c1cee0008f6778ff6\/'<\/span>,<span class=\"keyword\">...<\/span>\r\n    <span class=\"string\">'pulsar.csv'<\/span>]));\r\nx = linspace(0,93,size(data,2));\r\n\r\njoyPlot(data',x,4)\r\nset(gcf,<span class=\"string\">'position'<\/span>,[500,100,560,680],<span class=\"string\">'InvertHardcopy'<\/span>,<span class=\"string\">'off'<\/span>)\r\nset(gca,<span class=\"string\">'Visible'<\/span>,<span class=\"string\">'off'<\/span>, <span class=\"string\">'box'<\/span>,<span class=\"string\">'off'<\/span>,<span class=\"string\">'XTick'<\/span>,[],<span class=\"string\">'YTick'<\/span>,[])\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_joyPlot\/potw_joyPlot_01.png\" alt=\"\"> <p>The function has a number of options for customization. For example, you can add colors to the plot. In this case, the colors represent the mean values of each signal.<\/p><pre class=\"codeinput\">joyPlot(data',x,4,<span class=\"string\">'FaceColor'<\/span>,mean(data,2))\r\ncolorbar\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_joyPlot\/potw_joyPlot_02.png\" alt=\"\"> <p>If you have R2018b or newer, you may be interested in <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2020a\/matlab\/ref\/stackedplot.html\"><tt>stackedplot<\/tt><\/a>. It will display multiple signals with common x values on a stacked plot. It has an interactive cursor which displays the values. Note that for data sets such as this one which has many signals, the number of signals displayed is limited by the size of the figure.<\/p><pre class=\"language-matlab\">stackedplot(data')\r\n<\/pre><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_joyPlot\/stackedplot_example.png\" alt=\"\"> <\/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=11485#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/75147#comment\">comment<\/a> for Santiago.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_b61971a30bb2423ea103182658f9341d() {\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='b61971a30bb2423ea103182658f9341d ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' b61971a30bb2423ea103182658f9341d';\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 2020 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_b61971a30bb2423ea103182658f9341d()\"><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; R2020a<br><\/p><p class=\"footer\"><br>\r\n      Published with MATLAB&reg; R2020a<br><\/p><\/div><!--\r\nb61971a30bb2423ea103182658f9341d ##### 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\/75147 |joyPlot|> by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/8557334 Santiago\r\n% Benito>.\r\n%\r\n% I must admit that I was simply drawn by the visualization, rather than\r\n% the name of the function, as I was not familiar with the band or the\r\n% music album. It was interesting to read the\r\n% <https:\/\/www.vice.com\/en_us\/article\/gvd9aj\/the-story-behind-joy-divisions-iconic-iunknown-pleasuresi-album-cover\r\n% back story>.\r\n%\r\n% The visualization is a stacked plot with overlap, resembling a ridgeline.\r\n% Here is an example from the sample code that Santiago includes with his\r\n% entry.\r\n\r\ndata = readmatrix(websave('pulsar.csv',['https:\/\/gist.githubusercontent.com\/borgar\/',...\r\n    '31c1e476b8e92a11d7e9\/raw\/0fae97dab6830ecee185a63c1cee0008f6778ff6\/',...\r\n    'pulsar.csv']));\r\nx = linspace(0,93,size(data,2));\r\n\r\njoyPlot(data',x,4)\r\nset(gcf,'position',[500,100,560,680],'InvertHardcopy','off')\r\nset(gca,'Visible','off', 'box','off','XTick',[],'YTick',[])\r\n\r\n%%\r\n% The function has a number of options for customization. For example, you\r\n% can add colors to the plot. In this case, the colors represent the mean\r\n% values of each signal.\r\n\r\njoyPlot(data',x,4,'FaceColor',mean(data,2))\r\ncolorbar\r\n\r\n%%\r\n% If you have R2018b or newer, you may be interested in\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2020a\/matlab\/ref\/stackedplot.html\r\n% |stackedplot|>. It will display multiple signals with common x values on\r\n% a stacked plot. It has an interactive cursor which displays the values.\r\n% Note that for data sets such as this one which has many signals, the\r\n% number of signals displayed is limited by the size of the figure.\r\n%\r\n%   stackedplot(data')\r\n%\r\n% <<stackedplot_example.png>>\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=11485#respond here> or leave a\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/75147#comment\r\n% comment> for Santiago.\r\n\r\n##### SOURCE END ##### b61971a30bb2423ea103182658f9341d\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/pick\/files\/potw_joyPlot_01.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><p>Jiro's Pick this week is joyPlot by Santiago Benito.I must admit that I was simply drawn by the visualization, rather than the name of the function, as I was not familiar with the band or the music... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2020\/04\/27\/ridgeline-visualization\/\">read more >><\/a><\/p>","protected":false},"author":35,"featured_media":11495,"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\/11485"}],"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=11485"}],"version-history":[{"count":2,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/11485\/revisions"}],"predecessor-version":[{"id":11489,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/11485\/revisions\/11489"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media\/11495"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=11485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=11485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=11485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}