Main Content


Project text annotation on map axes


h = textm(...)


textm(lat,lon,string) projects the text in string onto the current map axes at the locations specified by the lat and lon. The units of lat and lon must match the 'angleunits' property of the map axes. If lat and lon contain multiple elements, textm places a text object at each location. In this case string may be a cell array of character vectors with the same number of elements as lat and lon. (For backward compatibility, string may also be a 2-D character array such that size(string,1) matches numel(lat)).

textm(lat,lon,z,string) draws the text at the altitude(s) specified in z, which must be the same size as lat and lon. The default altitude is 0.

textm(lat,lon,z,string,PropertyName,PropertyValue,...) sets the text object properties. All properties supported by the MATLAB® text function are supported by textm.

h = textm(...) returns the handles to the text objects drawn.


The feature of textm that distinguishes it from the standard MATLAB text function is that the text object is projected appropriately. Type the following:

axesm sinusoid

figure; axesm miller

The text 'hello' is placed at the same geographic point, but it appears to have moved relative to the axes because of the different projections. If you change the projection using the setm function, the text moves as necessary. Use text to fix text objects in the axes independent of projection.


You may be working with scalar lat and lon data or vector lat and lon data. If you are in scalar mode and you enter a cell array of character vectors, you will get a text object containing multiple lines. Also note that vertical slash characters, rather than producing multiple lines of text, yield a single line of text containing vertical slashes. On the other hand, if lat and lon are nonscalar, then the size of the cell array input must match their size exactly.

See Also


Introduced before R2006a