{"id":6312,"date":"2015-12-18T12:13:44","date_gmt":"2015-12-18T17:13:44","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=6312"},"modified":"2015-12-18T15:34:48","modified_gmt":"2015-12-18T20:34:48","slug":"scatter-bars","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2015\/12\/18\/scatter-bars\/","title":{"rendered":"Scatter Bars"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\n   <introduction><\/p>\n<p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495\">Sean<\/a>'s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/1420-scatterbar3\">scatterbar3<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/1297842-manu-raghavan\">Manu Raghavan<\/a>.\n      <\/p>\n<p>   <\/introduction><\/p>\n<h3>Contents<\/h3>\n<div>\n<ul>\n<li><a href=\"#1\">Drawing Bars<\/a><\/li>\n<li><a href=\"#5\">Drawing The Boston Skyline<\/a><\/li>\n<li><a href=\"#14\">Comments<\/a><\/li>\n<\/ul><\/div>\n<h3>Drawing Bars<a name=\"1\"><\/a><\/h3>\n<p>If you've ever wanted to draw a bar plot in MATLAB, you've probably come across: <tt><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2015b\/matlab\/ref\/bar.html\">bar<\/a><\/tt>, <tt><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2015b\/matlab\/ref\/barh.html\">barh<\/a><\/tt>, <tt><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2015b\/matlab\/ref\/bar3.html\">bar3<\/a><\/tt>, <tt><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2015b\/matlab\/ref\/bar3h.html\">bar3h<\/a><\/tt>, and maybe in newer releases <tt><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2015b\/matlab\/ref\/histogram.html\">histogram<\/a><\/tt> or <tt><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2015b\/matlab\/ref\/histogram2.html\">histogram2<\/a><\/tt>.\n   <\/p>\n<p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainscatterbarm\/bars.png\"> <\/p>\n<p>These allow you to do a variety of bar plots with with options for stacking and alignment.  For example,<\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">y = rand(5,1);\r\ny = [y 1-y];\r\nbars = bar3h(1:5,y,<span style=\"color: #A020F0\">'stacked'<\/span>);\r\nlegend(bars,{<span style=\"color: #A020F0\">'Type A'<\/span>,<span style=\"color: #A020F0\">'Type B'<\/span>})<\/pre>\n<p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainscatterbarm\/mainscatterbarm_01.png\"> <\/p>\n<p>Or:<\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">bars = bar(1:7,abs([0.7 0.5 0; 0.6 0.5 0; 0.55 0.5 0.1; 0.52 0.5 0.2; 0.4 0.5 0.4; 0.9 0 0.5; 0.9 0 0.4]));\r\nax = gca;\r\nax.YLim = [0 1];\r\nax.XTickLabel = day(datetime(1,1,1:7),<span style=\"color: #A020F0\">'shortname'<\/span>);\r\nlegend(bars,{<span style=\"color: #A020F0\">'Sleep'<\/span>,<span style=\"color: #A020F0\">'Coffee'<\/span>,<span style=\"color: #A020F0\">'Beer'<\/span>},<span style=\"color: #A020F0\">'location'<\/span>,<span style=\"color: #A020F0\">'northwest'<\/span>)<\/pre>\n<p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainscatterbarm\/mainscatterbarm_02.png\"> <\/p>\n<p>However these require a grid.  The grid does not have to be uniform but does have to be monotically increasing.<\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">histogram2(randn(100,1),randn(100,1))<\/pre>\n<p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainscatterbarm\/mainscatterbarm_03.png\"> <\/p>\n<h3>Drawing The Boston Skyline<a name=\"5\"><\/a><\/h3>\n<p>So what if I wanted to draw the Boston skyline?  Now I'll need a non-uniform grid.  To get the data into MATLAB, I copied<br \/>\n      the table from <a href=\"https:\/\/en.wikipedia.org\/wiki\/List_of_tallest_buildings_in_Boston\">Wikipedia<\/a> into Excel and then imported it into MATLAB as a <tt><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2015b\/matlab\/ref\/table.html\">table<\/a><\/tt>.\n   <\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">load <span style=\"color: #A020F0\">BostonBuildings<\/span>\r\ndisp(BostonBuildings)<\/pre>\n<pre style=\"font-style:oblique\">             BuildingName              BuildingHeight              LatLonDMS          \r\n    _______________________________    ______________    _____________________________\r\n    '200 Clarendon'                    '790 (241)'       '42&deg;20&#8242;57.4&#8243;N&nbsp;71&deg;04&#8242;29.2&#8243;W'  \r\n    'Prudential Tower'                 '749 (228)'       '42&deg;20&#8242;49.78&#8243;N&nbsp;71&deg;04&#8242;57.08&#8243;W'\r\n    'Millennium Tower'                 '685 (209)'       '42&deg;21&#8242;21.01&#8243;N&nbsp;71&deg;3&#8242;33.91&#8243;W' \r\n    'Federal Reserve Bank Building'    '614 (187)'       '42&deg;21&#8242;08.55&#8243;N&nbsp;71&deg;03&#8242;14.82&#8243;W'\r\n    'One Boston Place'                 '601 (183)'       '42&deg;21&#8242;31&#8243;N&nbsp;71&deg;03&#8242;30&#8243;W'      \r\n    'One International Place'          '600 (183)'       '42&deg;21&#8242;20.8&#8243;N&nbsp;71&deg;03&#8242;07.5&#8243;W'  \r\n    '100 Federal Street'               '591 (180)'       '42&deg;21&#8242;18&#8243;N&nbsp;71&deg;03&#8242;22&#8243;W'      \r\n    'One Financial Center'             '590 (180)'       '42&deg;21&#8242;08.6&#8243;N&nbsp;71&deg;03&#8242;23.0&#8243;W'  \r\n    '111 Huntington Avenue'            '554 (169)'       '42&deg;20&#8242;48.38&#8243;N&nbsp;71&deg;04&#8242;52.86&#8243;W'\r\n    'Two International Place'          '538 (164)'       '42&deg;21&#8242;23&#8243;N&nbsp;71&deg;03&#8242;06&#8243;W'      \r\n    'One Post Office Square'           '525 (160)'       '42&deg;21&#8242;25&#8243;N&nbsp;71&deg;03&#8242;19&#8243;W'      \r\n    'One Federal Street'               '520 (159)'       '42&deg;21&#8242;24&#8243;N&nbsp;71&deg;03&#8242;25&#8243;W'      \r\n    'Exchange Place'                   '510 (156)'       '42&deg;21&#8242;30&#8243;N&nbsp;71&deg;03&#8242;23&#8243;W'      \r\n    '60 State Street'                  '509 (155)'       '42&deg;21&#8242;33&#8243;N&nbsp;71&deg;03&#8242;23&#8243;W'      \r\n    'One Beacon Street'                '505 (154)'       '42&deg;21&#8242;30&#8243;N&nbsp;71&deg;03&#8242;39&#8243;W'      \r\n    'One Lincoln Street'               '503 (153)'       '42&deg;21&#8242;09&#8243;N&nbsp;71&deg;03&#8242;29&#8243;W'      \r\n    '28 State Street'                  '500 (152)'       '42&deg;21&#8242;34&#8243;N&nbsp;71&deg;03&#8242;27&#8243;W'      \r\n    'Custom House Tower'               '496 (151)'       '42&deg;21&#8242;32.65&#8243;N&nbsp;71&deg;03&#8242;12.13&#8243;W'\r\n    'Berkeley Building'                '495 (151)'       '42&deg;20&#8242;59.78&#8243;N&nbsp;71&deg;04&#8242;21.55&#8243;W'\r\n    '33 Arch Street'                   '477 (145)'       '42&deg;21&#8242;21&#8243;N&nbsp;71&deg;03&#8242;28&#8243;W'      \r\n    'State Street Bank Building'       '477 (145)'       '42&deg;21&#8242;22&#8243;N&nbsp;71&deg;03&#8242;15&#8243;W'      \r\n    'Millennium Place Tower I'         '475 (145)'       '42&deg;21&#8242;11&#8243;N&nbsp;71&deg;03&#8242;47&#8243;W'      \r\n    '125 High Street'                  '452 (138)'       '42&deg;21&#8242;19&#8243;N&nbsp;71&deg;03&#8242;12&#8243;W'      \r\n    '100 Summer Street'                '450 (137)'       '42&deg;21&#8242;14&#8243;N&nbsp;71&deg;03&#8242;27&#8243;W'      \r\n    'Millennium Place Tower II'        '446 (136)'       '42&deg;21&#8242;11&#8243;N&nbsp;71&deg;03&#8242;47&#8243;W'      \r\n    'McCormack Building'               '401 (122)'       '42&deg;21&#8242;34&#8243;N&nbsp;71&deg;03&#8242;44&#8243;W'      \r\n    'Keystone Building'                '400 (122)'       '42&deg;21&#8242;15&#8243;N&nbsp;71&deg;03&#8242;16&#8243;W'      \r\n    'Harbor Towers I'                  '400 (122)'       '42&deg;21&#8242;28.64&#8243;N&nbsp;71&deg;02&#8242;59.89&#8243;W'\r\n<\/pre>\n<p>I need to remove meters from height and convert latitude in Degrees-Minutes-Seconds (DMS) to latitude and longitude in degrees.<br \/>\n       First the height, all buildings have three digits so I'll turn the first three digits into a number.\n   <\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">BostonBuildings.BuildingHeight = cellfun(@(x)str2double(x(1:3)),BostonBuildings.BuildingHeight);<\/pre>\n<p>Next DMS to lat\/lon.  There's a nice function in the <a href=\"https:\/\/www.mathworks.com\/products\/mapping\/\">Mapping Toolbox<\/a>, <tt><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2015b\/map\/ref\/dms2degrees.html\">dms2degrees<\/a><\/tt>, to do exactly this. First, I need to split the strings into pieces. So far, I've taken the easy way to get the data in and manipulate it.  Now I'll make things harder on myself and wake my brain up for the day with some <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2015b\/matlab\/ref\/regexp.html\">regular expressions<\/a>.  Here's the expression:\n   <\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">expression = <span style=\"color: #A020F0\">'([\\d.]{1,5})'<\/span>;<\/pre>\n<p>Let me explain that in English:<\/p>\n<div>\n<ul>\n<li><tt>()<\/tt> around whole expression this captures the token, the string I'm matching so that I can use it later.  Use () and the <i>'tokens'<\/i> flag to extract the contents of the string.\n         <\/li>\n<li><tt>[]<\/tt> Allows anything inside of the brackets to count as a match.\n         <\/li>\n<li><tt>\\d.<\/tt> Says I can match digits, <tt>\\d<\/tt>, or periods.\n         <\/li>\n<li><tt>{1,5}<\/tt> This means I can match digits and periods 1 to 5 times to capture a single digit or 28.64, five digits long.\n         <\/li>\n<\/ul><\/div>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">t = regexp(BostonBuildings.LatLonDMS,expression,<span style=\"color: #A020F0\">'tokens'<\/span>);<\/pre>\n<p>The result is a cell because regexp doesn't know how many tokens it will match, if any.  Unpack the cell by vertically concatenating<br \/>\n      and then turning the first element of each resulting cell into a number (they're still strings):\n   <\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">dmsdms = vertcat(t{:});\r\ndmsdms = cellfun(@(x)str2double(x{1}),dmsdms);<\/pre>\n<p>Now we use the Mapping Toolbox function give us latitude and longitude in degrees and stick that back into the table.<\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">BostonBuildings.LatDeg = dms2degrees(dmsdms(:,1:3)); <span style=\"color: #228B22\">% First three lat<\/span>\r\nBostonBuildings.LonDeg = dms2degrees(dmsdms(:,4:6)); <span style=\"color: #228B22\">% Second three lon<\/span>\r\ndisp(BostonBuildings(1:5,{<span style=\"color: #A020F0\">'BuildingName'<\/span>,<span style=\"color: #A020F0\">'BuildingHeight'<\/span>,<span style=\"color: #A020F0\">'LatDeg'<\/span>,<span style=\"color: #A020F0\">'LonDeg'<\/span>}))<\/pre>\n<pre style=\"font-style:oblique\">             BuildingName              BuildingHeight    LatDeg    LonDeg\r\n    _______________________________    ______________    ______    ______\r\n    '200 Clarendon'                    790               42.349    71.075\r\n    'Prudential Tower'                 749               42.347    71.083\r\n    'Millennium Tower'                 685               42.356    71.059\r\n    'Federal Reserve Bank Building'    614               42.352    71.054\r\n    'One Boston Place'                 601               42.359    71.058\r\n<\/pre>\n<p>The locations are in latitude and longitude, I'll project them into x\/y for plotting using <tt><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2015b\/map\/ref\/projfwd.html\">projfwd<\/a><\/tt>.\n   <\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">[x, y] = projfwd(defaultm(<span style=\"color: #A020F0\">'mercator'<\/span>),BostonBuildings.LatDeg,BostonBuildings.LonDeg);<\/pre>\n<p>Finally, we can call scatterbar3 rescaling.<\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">scatterbar3(x*10,y*10,BostonBuildings.BuildingHeight,0.00025)\r\nax = gca;\r\nax.XTick = [];\r\nax.YTick = [];\r\nview(16,8) <span style=\"color: #228B22\">% Approximate view from Mass Pike Eastbound<\/span>\r\nzlabel(<span style=\"color: #A020F0\">'Height (ft)'<\/span>)<\/pre>\n<p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainscatterbarm\/mainscatterbarm_04.png\"> <\/p>\n<p>For those of you who live in or near Boston and have no clue what that third tallest building is, it's the Millenium<br \/>\n      Tower under construction right now.\n   <\/p>\n<h3>Comments<a name=\"14\"><\/a><\/h3>\n<p>Would having scatterbar3 be helpful to you?  What types of data would you want to visualize with it?<\/p>\n<p>Let us know by leaving a <a href=\"<https:\/\/blogs.mathworks.com\/pick\/?p=6312#respond\">here<\/a> comment here&gt; or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/1420-scatterbar3#comments\">comment<\/a> for Manu here.\n   <\/p>\n<p><script language=\"JavaScript\">\n<!--\n\n    function grabCode_9e2aaea24d0f456e94dc3272bcb17987() {\n        \/\/ Remember the title so we can use it in the new page\n        title = document.title;\n\n        \/\/ Break up these strings so that their presence\n        \/\/ in the Javascript doesn't mess up the search for\n        \/\/ the MATLAB code.\n        t1='9e2aaea24d0f456e94dc3272bcb17987 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 9e2aaea24d0f456e94dc3272bcb17987';\n    \n        b=document.getElementsByTagName('body')[0];\n        i1=b.innerHTML.indexOf(t1)+t1.length;\n        i2=b.innerHTML.indexOf(t2);\n \n        code_string = b.innerHTML.substring(i1, i2);\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\n\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \n        \/\/ in the XML parser.\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\n        \/\/ doesn't go ahead and substitute the less-than character. \n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\n\n        author = 'Sean de Wolski';\n        copyright = 'Copyright 2015 The MathWorks, Inc.';\n\n        w = window.open();\n        d = w.document;\n        d.write('\n\n<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\n\\n');\n      \n      d.title = title + ' (MATLAB code)';\n      d.close();\n      }   \n      \n-->\n<\/script><\/p>\n<p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><a href=\"javascript:grabCode_9e2aaea24d0f456e94dc3272bcb17987()\"><span style=\"font-size: x-small;        font-style: italic;\">Get<br \/>\n            the MATLAB code<br \/>\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><\/p>\n<p>      Published with MATLAB&reg; R2016a<\/p>\n<\/div>\n<p><!--\n9e2aaea24d0f456e94dc3272bcb17987 ##### SOURCE BEGIN #####\n%% Scatter Bars\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495 Sean>'s pick \n% this week is <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/1420-scatterbar3 \n% scatterbar3> by <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/1297842-manu-raghavan \n% Manu Raghavan>.\n%% Drawing Bars\n% If you've ever wanted to draw a bar plot in MATLAB, you've probably come across: \n% |<https:\/\/www.mathworks.com\/help\/releases\/R2015b\/matlab\/ref\/bar.html bar>|, |<https:\/\/www.mathworks.com\/help\/releases\/R2015b\/matlab\/ref\/barh.html \n% barh>|, |<https:\/\/www.mathworks.com\/help\/releases\/R2015b\/matlab\/ref\/bar3.html \n% bar3>|, |<https:\/\/www.mathworks.com\/help\/releases\/R2015b\/matlab\/ref\/bar3h.html \n% bar3h>|, and maybe in newer releases |<https:\/\/www.mathworks.com\/help\/releases\/R2015b\/matlab\/ref\/histogram.html \n% histogram>| or |<https:\/\/www.mathworks.com\/help\/releases\/R2015b\/matlab\/ref\/histogram2.html \n% histogram2>|.\n% \n% <<bars.png>>\n% \n% These allow you to do a variety of bar plots with with options for stacking \n% and alignment.  For example, \n\ny = rand(5,1);\ny = [y 1-y];\nbars = bar3h(1:5,y,'stacked');\nlegend(bars,{'Type A','Type B'})\n%% \n% \n% \n% Or:\n\nbars = bar(1:7,abs([0.7 0.5 0; 0.6 0.5 0; 0.55 0.5 0.1; 0.52 0.5 0.2; 0.4 0.5 0.4; 0.9 0 0.5; 0.9 0 0.4]));\nax = gca;\nax.YLim = [0 1];\nax.XTickLabel = day(datetime(1,1,1:7),'shortname');\nlegend(bars,{'Sleep','Coffee','Beer'},'location','northwest')\n%% \n% \n% \n% However these require a grid.  The grid does not have to be uniform but \n% does have to be monotically increasing.\n\nhistogram2(randn(100,1),randn(100,1))\n%% \n% \n%% Drawing The Boston Skyline\n% So what if I wanted to draw the Boston skyline?  Now I'll need a non-uniform \n% grid.  To get the data into MATLAB, I copied the table from <https:\/\/en.wikipedia.org\/wiki\/List_of_tallest_buildings_in_Boston \n% Wikipedia> into Excel and then imported it into MATLAB as a |<https:\/\/www.mathworks.com\/help\/releases\/R2015b\/matlab\/ref\/table.html \n% table>|.\n\nload BostonBuildings\ndisp(BostonBuildings)\n%% \n% I need to remove meters from height and convert latitude in Degrees-Minutes-Seconds \n% (DMS) to latitude and longitude in degrees.  First the height, all buildings \n% have three digits so I'll turn the first three digits into a number.\n\nBostonBuildings.BuildingHeight = cellfun(@(x)str2double(x(1:3)),BostonBuildings.BuildingHeight);\n%% \n% Next DMS to lat\/lon.  There's a nice function in the <https:\/\/www.mathworks.com\/products\/mapping\/ \n% Mapping Toolbox>, |<https:\/\/www.mathworks.com\/help\/releases\/R2015b\/map\/ref\/dms2degrees.html \n% dms2degrees>|, to do exactly this. First, I need to split the strings into pieces.  \n% So far, I've taken the easy way to get the data in and manipulate it.  Now I'll \n% make things harder on myself and wake my brain up for the day with some <https:\/\/www.mathworks.com\/help\/releases\/R2015b\/matlab\/ref\/regexp.html \n% regular expressions>.  Here's the expression:  \n\nexpression = '([\\d.]{1,5})';\n%% \n% Let me explain that in English:\n% \n% * |()| around whole expression this captures the token, the string I'm matching \n% so that I can use it later.  Use () and the _'tokens'_ flag to extract the contents \n% of the string.\n% * |[]| Allows anything inside of the brackets to count as a match.\n% * |\\d.| Says I can match digits, |\\d|, or periods.\n% * |{1,5}| This means I can match digits and periods 1 to 5 times to capture \n% a single digit or 28.64, five digits long.\n\nt = regexp(BostonBuildings.LatLonDMS,expression,'tokens');\n%% \n% The result is a cell because regexp doesn't know how many tokens it will \n% match, if any.  Unpack the cell by vertically concatenating and then turning \n% the first element of each resulting cell into a number (they're still strings):\n\ndmsdms = vertcat(t{:});\ndmsdms = cellfun(@(x)str2double(x{1}),dmsdms);\n%% \n% \n% \n% Now we use the Mapping Toolbox function give us latitude and longitude \n% in degrees and stick that back into the table.\n\nBostonBuildings.LatDeg = dms2degrees(dmsdms(:,1:3)); % First three lat\nBostonBuildings.LonDeg = dms2degrees(dmsdms(:,4:6)); % Second three lon\ndisp(BostonBuildings(1:5,{'BuildingName','BuildingHeight','LatDeg','LonDeg'}))\n%% \n% The locations are in latitude and longitude, I'll project them into x\/y \n% for plotting using |<https:\/\/www.mathworks.com\/help\/releases\/R2015b\/map\/ref\/projfwd.html \n% projfwd>|.\n\n[x, y] = projfwd(defaultm('mercator'),BostonBuildings.LatDeg,BostonBuildings.LonDeg);\n%% \n% \n% \n% Finally, we can call scatterbar3 rescaling.\n\nscatterbar3(x*10,y*10,BostonBuildings.BuildingHeight,0.00025)\nax = gca;\nax.XTick = [];\nax.YTick = [];\nview(16,8) % Approximate view from Mass Pike Eastbound\nzlabel('Height (ft)')\n%% \n% For those of you who live in or near Boston and have no clue what that \n% that third tallest building is, it's the Millenium Tower under construction \n% right now.\n% \n% \n%% Comments\n% Would having scatterbar3 be helpful to you?  What types of data would you \n% want to visualize with it?\n% \n% Let us know by leaving a <<https:\/\/blogs.mathworks.com\/pick\/?p=6312#respond \n% here> comment here> or leave a <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/1420-scatterbar3#comments \n% comment> for Manu here.\n% \n%\n##### SOURCE END ##### 9e2aaea24d0f456e94dc3272bcb17987\n--><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainscatterbarm\/bars.png\" onError=\"this.style.display ='none';\" \/><\/div>\n<p>Sean's pick this week is scatterbar3 by Manu Raghavan.<\/p>\n<p>Contents<\/p>\n<p>Drawing Bars<br \/>\nDrawing The Boston Skyline<br \/>\nComments<\/p>\n<p>Drawing Bars<br \/>\nIf you've ever wanted to draw a bar plot in MATLAB,... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2015\/12\/18\/scatter-bars\/\">read more >><\/a><\/p>\n","protected":false},"author":87,"featured_media":0,"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\/6312"}],"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\/87"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=6312"}],"version-history":[{"count":5,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/6312\/revisions"}],"predecessor-version":[{"id":6317,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/6312\/revisions\/6317"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=6312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=6312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=6312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}