MATLAB: Am I not able to see the output on the map axes using TEXTM function

axesmframemmaplatlimitmaplonlimitMATLABtextmvisible

I use AXESM to create map axes with specified 'MapLatLimit' and 'MapLonLimit' properties. Next, I use TEXTM to place some text at a location within the given map limits. The text is not visible in the figure. The reproduction steps are:
axesm('pcarree','MapLatLimit',[-20 20],'MapLonLimit',[-20 20]);
textm(-5,-5,'test');

Best Answer

An object is visible in a given axes if it lies within the limits specified by the axes properties XLIM and YLIM. By default, these limits are determined automatically from the extents of the visible non-text objects that are present in the axes.
In the given reproduction example, the text is not visible as it lies outside the default axes limits [0 0 1 1]. The solution is to call FRAMEM function after creating the map axes. If you do not wish the frame to be visible, or would like to delete it, that can be done after resetting the axes XLimMode and YLimMode to 'manual', as following:
axesm('pcarree','MapLatLimit',[-20 20],'MapLonLimit',[-20 20])
h = framem;
set(gca,'XLimMode','manual','YLimMode','manual')
set(h,'Visible','off')
textm(-5,-5,'test');