{"id":1526,"date":"2024-09-18T10:20:58","date_gmt":"2024-09-18T14:20:58","guid":{"rendered":"https:\/\/blogs.mathworks.com\/graphics-and-apps\/?p=1526"},"modified":"2024-10-03T11:09:02","modified_gmt":"2024-10-03T15:09:02","slug":"r2024b-release-whats-new-in-graphics-and-app-building","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/graphics-and-apps\/2024\/09\/18\/r2024b-release-whats-new-in-graphics-and-app-building\/","title":{"rendered":"R2024b release: What\u2019s new in Graphics and App Building?"},"content":{"rendered":"<p>Two of my favorite times of the year are September and March, when the landscape transforms beautifully in my area of the globe. These months also mark exciting transformations in the MATLAB world with new releases! I fondly remember eagerly scouring the <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/release-notes.html?startrelease=R2024a&amp;endrelease=R2024b&amp;rntext=&amp;groupby=release\">release notes<\/a> to uncover new features and being the first to share them with my peers in the lab. Now, I get to share these exciting updates with you! Here are some highlights of new graphics and app building features in R2024b. Stay tuned to the <a href=\"https:\/\/blogs.mathworks.com\/graphics-and-apps\">Graphics and App Building blog<\/a> for in-depth articles on some of these topics, often written by the primary developer in the project!<\/p>\n<p><a href=\"https:\/\/www.mathworks.com\/products\/new_products\/latest_features.html\">Download the latest release<\/a><\/p>\n<h2>New charts and graphics objects<\/h2>\n<p>Visualize the estimated probability density of your data using the new <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/violinplot.html\"><strong>violinplot<\/strong><\/a>, combining elements of a <span style=\"font-family: monospace\">boxchart<\/span> and <span style=\"font-family: monospace\">swarmchart<\/span> to evaluate and compare groups of data. \u00a0\u00a0The figure below plots the same set of data using various tools to visualize distributions. Observe how <span style=\"font-family: monospace\">violinplot<\/span> smoothly extends beyond the range of data, providing a visual estimate of the data\u2019s distribution beyond the observed values.<\/p>\n<pre style=\"padding-left: 40px\"><strong>violinplot(M)<\/strong><\/pre>\n<p style=\"padding-left: 40px\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"531\" class=\"size-large wp-image-1586 alignnone\" src=\"http:\/\/blogs.mathworks.com\/graphics-and-apps\/files\/2024\/09\/24b_violinplot-1024x531.png\" alt=\"\" \/><\/p>\n<p>Enhance your map visualizations by displaying icons in GeographicAxes or MapAxes using the new <a href=\"https:\/\/www.mathworks.com\/help\/map\/ref\/map.graphics.chart.primitive.iconchart-properties.html\"><strong>IconChart<\/strong><\/a> object, generated by the <a href=\"https:\/\/www.mathworks.com\/help\/map\/ref\/geoiconchart.html\"><strong>geoiconchart<\/strong><\/a> function (Mapping Toolbox). \u00a0Check out this map of domestic airports near MathWorks HQ. No need for a legend with these icons!<\/p>\n<pre style=\"padding-left: 40px\"><strong>geoiconchart(lat, lon, <span style=\"color: #a02b93\">'MWlogo.png'<\/span>, SizeData=30)<\/strong>\r\n<strong>geoiconchart(lat, lon, <span style=\"color: #a02b93\">'airplane.png'<\/span>, SizeData=30)<\/strong><\/pre>\n<p style=\"padding-left: 40px\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"546\" class=\"size-large wp-image-1580 alignnone\" src=\"http:\/\/blogs.mathworks.com\/graphics-and-apps\/files\/2024\/09\/24b_iconchart-1024x546.png\" alt=\"\" \/><\/p>\n<p><a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/compassplot.html\"><strong>compassplot<\/strong><\/a> joins the polar axes family to provide an easy way to visualize your radial data. Anyone using the older <span style=\"font-family: monospace\">compass()<\/span> function, built in Cartesian coordinates, is encouraged to make the switch to <span style=\"font-family: monospace\">compassplot<\/span> to take advantage of <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/matlab.graphics.axis.polaraxes-properties.html\">PolarAxes properties<\/a>. See our <a href=\"https:\/\/blogs.mathworks.com\/graphics-and-apps\/2024\/10\/03\/a_grown-up-compassplot\/\">deep-dive into compassplot<\/a>.<\/p>\n<pre style=\"padding-left: 40px\">\u00a0compassplot(windDirection, windSpeed)<\/pre>\n<p style=\"padding-left: 40px\"><img decoding=\"async\" loading=\"lazy\" width=\"834\" height=\"672\" class=\"size-full wp-image-1571 alignnone\" src=\"http:\/\/blogs.mathworks.com\/graphics-and-apps\/files\/2024\/09\/24b_compassplot.png\" alt=\"\" \/><\/p>\n<p>My favorite new R2024b feature in this category is the <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/matlab.graphics.chart.decoration.constantplane-properties.html\"><strong>ConstantPlane<\/strong><\/a><strong>, <\/strong>generated by the<strong> <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/constantplane.html\">constantplane()<\/a><\/strong> function. Similar to <span style=\"font-family: monospace\">ConstantLine<\/span> objects (<span style=\"font-family: monospace\">xline<\/span>, <span style=\"font-family: monospace\">yline<\/span>, R2018b) and <span style=\"font-family: monospace\">ConstantRegion<\/span> (<span style=\"font-family: monospace\">xregion<\/span>, <span style=\"font-family: monospace\">yregion<\/span>, R2023a), constant planes extend infinitely and have many use cases to enhance and annotate 3D visualizations.\u00a0 The example below uses a <span style=\"font-family: monospace\">ConstantPlane<\/span> to show a 2D slice of a modified LCH colorspace at 80% lightness. Without the plane, it would be difficult to see the chroma border of the 3D volume at this lightness value.<\/p>\n<pre style=\"padding-left: 40px\">constantplane(<span style=\"color: #a02b93\">'y'<\/span>,0.7)<\/pre>\n<p style=\"padding-left: 40px\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"563\" class=\"size-large wp-image-1574 alignnone\" src=\"http:\/\/blogs.mathworks.com\/graphics-and-apps\/files\/2024\/09\/24b_constantplane-1024x563.png\" alt=\"\" \/><\/p>\n<h2>Charting features and enhancements<\/h2>\n<p>We\u2019ve noticed that people frequently label bars in a bar plot and sometimes get stuck fumbling around with text placement or alignment.\u00a0 Now <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/matlab.graphics.chart.primitive.bar-properties.html#mw_28a09499-da72-40f1-8287-e34c8097b6ff\"><strong>bar has a Labels property<\/strong><\/a> along with label customization options. A great application of this feature is labeling stacked bars with the raw data to see the length of each segment. Notice that we also take care of choosing a default font color based on the bar color.<\/p>\n<pre style=\"padding-left: 40px\">h=bar(M,<span style=\"color: #a02b93\">'stacked'<\/span>)\r\nh(1).Labels = M(:,1);<\/pre>\n<p style=\"padding-left: 40px\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"560\" class=\"size-large wp-image-1562 alignnone\" src=\"http:\/\/blogs.mathworks.com\/graphics-and-apps\/files\/2024\/09\/24b_barlabels-1024x560.png\" alt=\"\" \/><\/p>\n<p>Are your legends taking up too much space because of wide legend icons?\u00a0 Control the width of legends using the new <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/matlab.graphics.illustration.legend-properties.html#mw_a18598dd-6da8-49a6-93a3-3304acb675ec\"><strong>IconColumnWidth<\/strong><\/a> property. The figure below shows the default legend width compared to a minimal legend width. I also snuck in two constant planes.<\/p>\n<pre style=\"padding-left: 40px\">legend(ax,<span style=\"color: #a02b93\">'IconColumnWidth'<\/span>,10)<\/pre>\n<p style=\"padding-left: 40px\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"319\" class=\"size-large wp-image-1583 alignnone\" src=\"http:\/\/blogs.mathworks.com\/graphics-and-apps\/files\/2024\/09\/24b_iconwidth-1024x319.png\" alt=\"\" \/><\/p>\n<p>Pie charts and donut charts can quickly become cluttered with many sparsely populated categories. Now you can group those items in an \u201cOthers\u201d category by setting the <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/matlab.graphics.chart.donutchart-properties.html#mw_17969056-69d6-407d-b2c0-706b902cc5c8_sep_mw_12708dd2-18bd-476f-a5dd-eeef7d59f51f\"><strong>NumDisplayWedges<\/strong><\/a>. This example below also shows the new <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/matlab.graphics.chart.donutchart-properties.html#mw_c8f74f88-38e8-407f-a94b-69eaef452091\"><strong>DisplayOrder<\/strong><\/a> property that sorts the categories in ascending or descending order. Compare these two donut charts below that contain the same set of data but the one on the right caps the number of categories and sorts them.<\/p>\n<pre style=\"padding-left: 40px\">donutchart(tbl,<span style=\"color: #a02b93\">'Country'<\/span>,DisplayOrder=<span style=\"color: #a02b93\">'descend'<\/span>,NumDisplayWedges=10)<\/pre>\n<p style=\"padding-left: 40px\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"298\" class=\"size-large wp-image-1565 alignnone\" src=\"http:\/\/blogs.mathworks.com\/graphics-and-apps\/files\/2024\/09\/24b_bieNumWedges-1024x298.png\" alt=\"\" \/><\/p>\n<p><a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/tiledlayout.html#d126e1860667\"><strong>tiledlayout()<\/strong><\/a>, with no inputs, now defaults to a \u201cflow\u201d arrangement that updates the grid size any time a new axes is added using <span style=\"font-family: monospace\">nexttile()<\/span>.\u00a0 This is one of the charting team\u2019s favorite enhancements and makes it even easier to flexibly add axes to a figure in an adaptive grid layout.<\/p>\n<pre style=\"padding-left: 40px\">tiledlayout()\r\nplot(nexttile(), __)\r\nsurface(nexttile(), __)\r\nhistogram(nexttile(), __)<\/pre>\n<h2>New App building features<\/h2>\n<p>UI Button and UI StateButton objects now have an <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/matlab.ui.control.button.html#mw_c5880ceb-dbf1-45f4-949d-3cbf7c90c668\"><strong>interpreter property<\/strong><\/a> that supports a wide range of tex, latex, and html markup options for greater customization.<\/p>\n<pre style=\"padding-left: 40px\">btn = uibutton(fig, <span style=\"color: #a02b93\"><strong>'Text'<\/strong><\/span>, . . .\r\n\u00a0<span style=\"color: #a02b93\">\"&lt;strong&gt;Delete data&lt;\/strong&gt;&lt;br&gt;\"<\/span> + . . .\r\n\u00a0\u00a0\u00a0 <span style=\"color: #a02b93\">\"&lt;mark&gt;&lt;strong&gt;I know what I'm doing&lt;\/strong&gt;&lt;\/mark&gt;\"<\/span>, . . .\r\n\u00a0\u00a0\u00a0<span style=\"color: #a02b93\"> <strong>'Interpreter'<\/strong><\/span>, <span style=\"color: #a02b93\">'html'<\/span>, <span style=\"color: #a02b93\"><strong>'Position'<\/strong><\/span>, [100 100 150 45]);<\/pre>\n<p style=\"padding-left: 40px\"><img decoding=\"async\" loading=\"lazy\" width=\"261\" height=\"113\" class=\"size-full wp-image-1568 alignnone\" src=\"http:\/\/blogs.mathworks.com\/graphics-and-apps\/files\/2024\/09\/24b_buttonInterpreter.png\" alt=\"\" \/><\/p>\n<p>Dragging UI components into a gridded layout in App Designer\u2019s Design Mode just got a whole lot easier by supporting multiple cell spans. See more tips on <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/creating_guis\/using-grid-layout-managers.html\">using grid layout managers in App Designer<\/a>.<\/p>\n<p style=\"padding-left: 40px\"><img decoding=\"async\" loading=\"lazy\" width=\"664\" height=\"456\" class=\"size-full wp-image-1577 alignnone\" src=\"http:\/\/blogs.mathworks.com\/graphics-and-apps\/files\/2024\/09\/24b_gridlayout.gif\" alt=\"\" \/><\/p>\n<h2>Some cleanup on our end<\/h2>\n<p><strong>opengl()<\/strong> - In a future release, changing the renderer using <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/opengl.html\"><span style=\"font-family: monospace\">opengl()<\/span><\/a> will no longer be necessary and this function will be removed. Starting with this release, you\u2019ll see a warning when using <span style=\"font-family: monospace\">opengl()<\/span>.\u00a0 Use <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/rendererinfo.html\">rendererinfo<\/a> to query renderer information.<\/p>\n<p><strong>legend outputs<\/strong> \u2013 We\u2019ve been actively enhancing the <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/legend.html\"><span style=\"font-family: monospace\">legend()<\/span><\/a> function based on our observations of how users were utilizing its undocumented outputs. Since R2018b, <span style=\"font-family: monospace\">legend()<\/span> has had only one documented output, the Legend object handle, and the documentation has warned against using additional undocumented outputs since R2016a. In a future release, requesting multiple outputs from legend will no longer be supported, with a warning appearing in R2024b. \u00a0If you still rely on multiple outputs to legend, we\u2019d love to hear your use case in the comments below.<\/p>\n<p><strong>hold all<\/strong> - Last year an <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/answers\">Answers forum<\/a> contributor and Community Advisory Board member, <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/5349647\">goc3<\/a>, brought to our <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/discussions\/general\/800795-to-hold-or-not-to-hold\/2529659#reply_2529659\">attention<\/a> that the <strong><span style=\"font-family: monospace\">hold all<\/span><\/strong> command contains a warning in the documentation stating it is the same as <strong><span style=\"font-family: monospace\">hold on<\/span><\/strong> and will be removed.\u00a0 He\u2019s right!\u00a0 So, we removed <span style=\"font-family: monospace\">hold all<\/span> from the documentation, but it continues to be an alias for <span style=\"font-family: monospace\">hold on<\/span>.\u00a0 We recommend replacing any references to <span style=\"font-family: monospace\">hold all<\/span> with <span style=\"font-family: monospace\">hold on<\/span>, if any still exist out there.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/graphics-and-apps\/files\/2024\/09\/24bNewFeaturesCoverImage.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div>\n<p>Two of my favorite times of the year are September and March, when the landscape transforms beautifully in my area of the globe. These months also mark exciting transformations in the MATLAB world... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/graphics-and-apps\/2024\/09\/18\/r2024b-release-whats-new-in-graphics-and-app-building\/\">read more >><\/a><\/p>\n","protected":false},"author":198,"featured_media":1595,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,14,2,20,1],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/graphics-and-apps\/wp-json\/wp\/v2\/posts\/1526"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/graphics-and-apps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/graphics-and-apps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/graphics-and-apps\/wp-json\/wp\/v2\/users\/198"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/graphics-and-apps\/wp-json\/wp\/v2\/comments?post=1526"}],"version-history":[{"count":17,"href":"https:\/\/blogs.mathworks.com\/graphics-and-apps\/wp-json\/wp\/v2\/posts\/1526\/revisions"}],"predecessor-version":[{"id":1952,"href":"https:\/\/blogs.mathworks.com\/graphics-and-apps\/wp-json\/wp\/v2\/posts\/1526\/revisions\/1952"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/graphics-and-apps\/wp-json\/wp\/v2\/media\/1595"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/graphics-and-apps\/wp-json\/wp\/v2\/media?parent=1526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/graphics-and-apps\/wp-json\/wp\/v2\/categories?post=1526"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/graphics-and-apps\/wp-json\/wp\/v2\/tags?post=1526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}