{"id":2985,"date":"2010-11-08T22:24:01","date_gmt":"2010-11-08T21:24:01","guid":{"rendered":"http:\/\/www.walkingrandomly.com\/?p=2985"},"modified":"2010-11-09T10:57:07","modified_gmt":"2010-11-09T09:57:07","slug":"5-new-plot-commands-in-mathematica-8","status":"publish","type":"post","link":"https:\/\/walkingrandomly.com\/?p=2985","title":{"rendered":"5 new plot commands in Mathematica 8"},"content":{"rendered":"<p>Mathematica 8 is coming and it&#8217;s chock-full of new features.\u00a0 Last month I took a very brief <a href=\"https:\/\/www.walkingrandomly.com\/?p=2933\">look at some of the new control systems functionality<\/a> that we&#8217;ll be getting and this time around I thought I would take a look at some of the new plotting functions.<\/p>\n<p>The first new command that I&#8217;d like to show you is a revamped <a href=\"http:\/\/en.wikipedia.org\/wiki\/Box_plot\">box and whisker plot<\/a>.  Mathematica 7 could do these as part of the StatisticalPlots package but they seemed a bit of an afterthought and didn&#8217;t have many options.<\/p>\n<pre>Needs[\"StatisticalPlots`\"]\r\ndata1 = RandomReal[NormalDistribution[0, 1], 100];\r\ndata2 = RandomReal[{0, 1}, 100];\r\nBoxWhiskerPlot[data1, data2]\r\n<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.walkingrandomly.com\/images\/mathematica8\/charts\/Box_Whisker_old.png\" alt=\"Mathematica 7 Box and Whisker\" \/><br \/>\nThe above code still works in Mathematica 8 but you&#8217;ll be told that it&#8217;s obsolete.  The new way of doing things is to use BoxWhiskerChart which looks better, has a boat load of new options and also comes with a very nice tool-tip.<\/p>\n<pre>data = Table[\r\n   RandomVariate[NormalDistribution[mu, 1],\r\n    100], {mu, {0, 3, 2, 5}}];\r\nBoxWhiskerChart[data, ChartElementFunction -&gt; \"GlassBoxWhisker\"]\r\n<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.walkingrandomly.com\/images\/mathematica8\/charts\/Box_whisker.png\" alt=\"Mathematica 8 Box and Whisker\" \/><\/p>\n<pre>BoxWhiskerChart[RandomVariate[NormalDistribution[], {5, 100}],\r\n ChartStyle -&gt; \"SandyTerrain\",\r\n ChartLegends -&gt; {\"a\", \"b\", \"c\", \"d\", \"e\"}]\r\n<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.walkingrandomly.com\/images\/mathematica8\/charts\/box_whisker_2.png\" alt=\"Mathematica 8 Box and Whisker\" \/><br \/>\nNext up is something from the world of Finance &#8211; a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Kagi_chart\">Kagi Chart<\/a>.<\/p>\n<pre>data = FinancialData[\"L:LLOY\",\r\n   \"Close\", {{2010, 6, 1}, {2010, 11, 1}, \"Day\"}];\r\nKagiChart[data, TrendStyle -&gt; {Green, Red}]\r\n<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.walkingrandomly.com\/images\/mathematica8\/charts\/kagi.png\" alt=\"Mathematica 8 Kagi Chart\" \/><br \/>\nHow about some wavelets?  Let&#8217;s do a discrete wavelet transform of a photo of me and use WaveletImagePlot to show the wavelet image coefficients.<\/p>\n<pre>me = Import[\"me.jpg\"];\r\ndwd = DiscreteWaveletTransform[me, Automatic, 3];\r\nWaveletImagePlot[dwd, ImageSize -&gt; 200]\r\n<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.walkingrandomly.com\/images\/mathematica8\/charts\/WaveletImage.png\" alt=\"Mathematica 8 WaveletImagePlot\" \/><br \/>\nNext up is a plot-type that is completely new to me &#8211; <a href=\"http:\/\/en.wikipedia.org\/wiki\/Violin_plot\">A violin plot<\/a>.<\/p>\n<pre>DistributionChart[RandomVariate[NormalDistribution[0, 1], {4, 100}],\r\n ChartElementFunction -&gt;\r\n  ChartElementData[\"SmoothDensity\", \"ColorScheme\" -&gt; \"DeepSeaColors\"]]\r\n<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.walkingrandomly.com\/images\/mathematica8\/charts\/distribution_chart.png\" alt=\"Mathematica 8 Violin Plot\" \/><br \/>\nFinally, A little more control systems with a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Root_locus\">Root Locus<\/a> Plot.<\/p>\n<pre>RootLocusPlot[\r\n StateSpaceModel[{{{0, 1}, {-3, -2}}, {{0}, {1}}, k {{2, 1}}}], {k, 0,\r\n   8}]\r\n<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.walkingrandomly.com\/images\/mathematica8\/charts\/Root_locus.png\" alt=\"Mathematica 8 Root Locus Plot\" \/><br \/>\nWhat I like most about all of these new plot types is that they will be built in to core Mathematica as of version 8 &#8211; no add-ons necessary.  Compare this to MATLAB which has functions for most of the above plots but only if you buy the relevant toolbox:<\/p>\n<ul>\n<li>Box and Whisker Plot &#8211; Statistics Toolbox<\/li>\n<li>Kagi Chart &#8211; Finance Toolbox<\/li>\n<li>Wavelet coefficients &#8211; Wavelet Toolbox<\/li>\n<li>Root locus plot &#8211; Control Systems Toolbox<\/li>\n<li>Violin Plot &#8211; ?????<\/li>\n<\/ul>\n<p>I much prefer Mathematica&#8217;s all in one approach and I am really looking forward to this release.\u00a0 Thanks to Wolfram Research for allowing me to release this little preview.<\/p>\n<p>How about you?\u00a0 What plot types are you hoping for in Mathematica 8?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mathematica 8 is coming and it&#8217;s chock-full of new features.\u00a0 Last month I took a very brief look at some of the new control systems functionality that we&#8217;ll be getting and this time around I thought I would take a look at some of the new plotting functions. The first new command that I&#8217;d like [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,8],"tags":[],"class_list":["post-2985","post","type-post","status-publish","format-standard","hentry","category-math-software","category-mathematica"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3swhs-M9","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/2985","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2985"}],"version-history":[{"count":8,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/2985\/revisions"}],"predecessor-version":[{"id":2992,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/2985\/revisions\/2992"}],"wp:attachment":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2985"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2985"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2985"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}