{"id":315,"date":"2011-12-20T14:00:17","date_gmt":"2011-12-20T19:00:17","guid":{"rendered":"https:\/\/blogs.mathworks.com\/loren\/?p=315"},"modified":"2011-12-21T10:03:51","modified_gmt":"2011-12-21T15:03:51","slug":"ginger-plot-winner","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/loren\/2011\/12\/20\/ginger-plot-winner\/","title":{"rendered":"Ginger Plot Winner"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <introduction>\r\n      <p>If you've been following the comments from my <a href=\"https:\/\/blogs.mathworks.com\/loren\/2011\/12\/07\/pretty-2-dimensional-chaotic-maps\/\">recent post<\/a> on chaotic maps, you know that there were several entries to the challenge of coming up with an interesting visualization.\r\n         The entries are each interesting, displaying schemes, including an animation, and extra information placed on the plots in\r\n         various ways. I have conferred with a few colleagues here and we have chosen the contribution from Rafael Oliveira as the\r\n         winning entry.  Why?  Because the code is interesting, he made interesting use interesting of some functions, the and the\r\n         plot is cute (at least for <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011b\/techdoc\/ref\/rng.html\"><tt>rng(42)<\/tt><\/a>.\r\n      <\/p>\r\n   <\/introduction>\r\n   <h3>Contents<\/h3>\r\n   <div>\r\n      <ul>\r\n         <li><a href=\"#1\">Adorned Ginger Man<\/a><\/li>\r\n         <li><a href=\"#3\">The Code<\/a><\/li>\r\n         <li><a href=\"#4\">Thanks for Participating<\/a><\/li>\r\n      <\/ul>\r\n   <\/div>\r\n   <h3>Adorned Ginger Man<a name=\"1\"><\/a><\/h3>\r\n   <p>Here's Rafael's adorned gingerman.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">gingerR<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/300\/gingerWinner_01.png\"> <p>Here's a comment from Rafael for this submission:<\/p>\r\n   <p><i>I decided to make a pixelated gingerbread man with the output of the chaotic map, using a lemniscate of Gerono as his green\r\n         bow tie :)<\/i><\/p>\r\n   <h3>The Code<a name=\"3\"><\/a><\/h3>\r\n   <p>I took the liberty of adding a small number of comments to Rafael's code to highlight some parts of the plot.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">type <span style=\"color: #A020F0\">gingerR<\/span><\/pre><pre style=\"font-style:oblique\">\r\nfunction gingerR\r\n%function pixelatedGBM from Rafael\r\n    rng(42) % could comment this out to get other \"men\"\r\n    [x,y] = gingerbreadman;\r\n    % scale and rotate our gingerbread man\r\n    r = [x y] * [cosd(135) -sind(135); sind(135) cosd(135)];\r\n    minR = min(r); maxR = max(r);\r\n    r = (r - repmat(minR,size(r,1),1)).\/repmat(maxR-minR,size(r,1),1);\r\n    r(:,2) = r(:,2).^1.5;\r\n    \r\n    % create a pixel representation of it\r\n    N = 25;\r\n    b = linspace(0,1,N);\r\n    dif = b(2)-b(1);\r\n    [xb,yb] = meshgrid(b,b);\r\n    \r\n    C = zeros(N);\r\n    x = r(:,1); y = r(:,2);\r\n    for i = 1:numel(xb)\r\n        C(i) = length(find(x &gt;= xb(i) &amp; x &lt; xb(i) +dif &amp; y &gt;= yb(i) ...\r\n            &amp; y &lt; yb(i)+dif));\r\n    end\r\n    C = reshape(C,size(xb));\r\n    % smooth a little for better results\r\n    smooth = @(A,L) ((eye(size(A,1)) + ...\r\n        L ^ 2 * diff(eye(size(A,1)),2)' * diff(eye(size(A,1)),2) + ...\r\n        2 * L * diff(eye(size(A,1)))' * diff(eye(size(A,1)))) \\ A);\r\n    D = smooth(smooth(C,0.1)',0.1)';\r\n    \r\n    % let's draw it :)\r\n    set(figure,'Position',[0 0 300 400],'Color',[1 1 1])\r\n    movegui(gcf,'center')\r\n    set(surf(xb,yb,zeros(size(D)),D),'ZData',xb.*0-0.01);\r\n    view(2); shading flat; grid off; axis off equal;\r\n    colormap([1 1 1; pink(19)])\r\n    hold on\r\n    t = linspace(0,2*pi,50);\r\n    % bowtie\r\n    set(fill((sin(t))\/9+0.5,(sin(2*t))\/18+0.65,[0 .8 0]),...\r\n        'EdgeAlpha',0)\r\n    set(fill((sin(t))\/30+0.5,(cos(t))\/30+0.65,[0 .9 0]),...\r\n        'EdgeAlpha',0)\r\n    t = linspace(0,2*pi,5);\r\n    % buttons\r\n    set(fill((sin(t))\/20+0.5,(cos(t))\/20+0.5,[.8 0 0]),'EdgeAlpha',0)\r\n    set(fill((sin(t))\/20+0.5,(cos(t))\/20+0.3,[.8 0 0]),'EdgeAlpha',0)\r\n    % sugar\r\n    plot3(r(1:10:end,1),r(1:10:end,2),r(1:10:end,1)*0-0.005,'.',...\r\n        'MarkerSize',3,'MarkerEdgeColor',[1 1 1]);\r\nend\r\n\r\n<\/pre><h3>Thanks for Participating<a name=\"4\"><\/a><\/h3>\r\n   <p>I really appreciate all the effort the contributors made.  The decision was tough.  I encourage you all to grab some of the\r\n      contributions from the comments in the previous post and play with them yourselves.\r\n   <\/p>\r\n   <p>Let me also take this moment to wish all of you a happy, healthy holiday season and new year!<\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_1725a6a78fb442b5a429e4b2d6b90442() {\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='1725a6a78fb442b5a429e4b2d6b90442 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 1725a6a78fb442b5a429e4b2d6b90442';\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        author = 'Loren Shure';\r\n        copyright = 'Copyright 2011 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 author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\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      \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_1725a6a78fb442b5a429e4b2d6b90442()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; 7.13<br><\/p>\r\n<\/div>\r\n<!--\r\n1725a6a78fb442b5a429e4b2d6b90442 ##### SOURCE BEGIN #####\r\n%% Ginger Plot Winner\r\n% If you've been following the comments from my\r\n% <https:\/\/blogs.mathworks.com\/loren\/2011\/12\/07\/pretty-2-dimensional-chaotic-maps\/\r\n% recent post> on chaotic maps, you know that there were several entries to\r\n% the challenge of coming up with an interesting visualization.  The\r\n% entries are each interesting, displaying schemes, including an animation,\r\n% and extra information placed on the plots in various ways. I have\r\n% conferred with a few colleagues here and we have chosen the contribution\r\n% from Rafael Oliveira as the winning entry.  Why?  Because the code is\r\n% interesting, he made interesting use interesting of some functions, the\r\n% and the plot is cute (at least for\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2011b\/techdoc\/ref\/rng.html\r\n% |rng(42)|>.\r\n%% Adorned Ginger Man\r\n% Here's Rafael's adorned gingerman.\r\ngingerR\r\n%%\r\n% Here's a comment from Rafael for this submission: \r\n%\r\n% _I decided to make a\r\n% pixelated gingerbread man with the output of the chaotic map, using a\r\n% lemniscate of Gerono as his green bow tie :)_\r\n%% The Code\r\n% I took the liberty of adding a small number of comments to Rafael's code\r\n% to highlight some parts of the plot.\r\ntype gingerR\r\n%% Thanks for Participating\r\n% I really appreciate all the effort the contributors made.  The decision\r\n% was tough.  I encourage you all to grab some of the contributions from\r\n% the comments in the previous post and play with them yourselves.\r\n%\r\n% Let me also take this moment to wish all of you a happy, healthy holiday\r\n% season and new year!\r\n\r\n\r\n\r\n##### SOURCE END ##### 1725a6a78fb442b5a429e4b2d6b90442\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   \r\n      If you've been following the comments from my recent post on chaotic maps, you know that there were several entries to the challenge of coming up with an interesting visualization.\r\n    ... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/loren\/2011\/12\/20\/ginger-plot-winner\/\">read more >><\/a><\/p>","protected":false},"author":39,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[33],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/315"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/users\/39"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/comments?post=315"}],"version-history":[{"count":5,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/315\/revisions"}],"predecessor-version":[{"id":329,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/315\/revisions\/329"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/media?parent=315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/categories?post=315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/tags?post=315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}