MATLAB: Is stem plot not appearing when using “stem3m” with “usamap” or “worldmap”

Mapping Toolboxplotscalestemusamap

I am trying to create a 3-D stem plot using "stem3m" on a map of the US created by "usamap", but the stem plot is not appearing.
Here is my code:
% initialize figure and map axis
figure(1);
ax = usamap('conus');
% draw states with random colors
states = shaperead('usastatelo', 'UseGeoCoords', true,...
'Selector',...
{@(name) ~any(strcmp(name,{'Alaska','Hawaii'})), 'Name'});
faceColors = makesymbolspec('Polygon',...
{'INDEX', [1 numel(states)], 'FaceColor', ...
polcmap(numel(states))}); %NOTE - colors are random
geoshow(ax, states, 'DisplayType', 'polygon', ...
'SymbolSpec', faceColors)
% draw stem plot
ptlat = [40 34 41 30 33]';
ptlon = [-73 -118 -87 -95 -112]';
%New York, Los Angeles, Chicago, Houston, Phoenix
ptz = [1 1.5 2 .5 1]';
stem3m(ptlat,ptlon,ptz, 'r-', 'LineWidth', 3);
% change view to see stem plot
view(3);
 

Best Answer

The issue is that the height of the bars is too small.
According to the documentation of "usamap" (https://www.mathworks.com/help/map/ref/usamap.html):
All axes created with "usamap" are initialized with a spherical Earth model having a radius of 6,371,000 meters.
This means that the scale of the axis is very large. This is also true for "worldmap".
Here are two ways to achieve the desired result:
1) Scale up "ptz" by multiplying by a large number.
For example, multiplying "ptz" by 1,000,000 makes the bars a reasonable height:
ptz = 1e6 * [1 1.5 2 .5 1]';
\n
2) Change the "DataAspectRatio" of the axis.
For example, to achieve the same result as the first method, add the following line of code:
ax.DataAspectRatio = [1 1 1/1e6];