Main Content

geotickformat

Set or query geographic tick label format

Description

example

geotickformat fmt sets the format of the latitude and longitude tick labels for the current geographic axes. When you use this syntax, you do not need to enclose the fmt argument in quotes. For example, the command geotickformat dd sets the tick label format to decimal degrees.

geotickformat(fmt) sets the tick label format for the current geographic axes. When you use this syntax, enclose the fmt input in single or double quotes, for example geotickformat('dd').

geotickformat(gx,fmt) sets the tick label format for the geographic axes specified by gx instead of the current geographic axes.

tickLabelFormat = geotickformat returns the tick label format for the current geographic axes.

tickLabelFormat = geotickformat(gx) returns the tick label format for the geographic axes specified by gx.

Examples

collapse all

Set the tick label format for a geographic plot using geotickformat.

First, specify the coordinates of the three largest cities in Brazil.

lat = [-23.5500   -22.9083   -15.7939];
lon = [-46.6333   -43.1964   -47.8828];

Plot the coordinates and add text labels.

geoplot(lat,lon,'r.','MarkerSize',8)
geolimits([-25 -16], [-54 -38])
text(lat,lon,["Sao Paulo","Rio de Janeiro","Brasilia"])

Change the tick label format to decimal degrees using geotickformat. The cardinal directions of south and west are indicated by a minus sign.

geotickformat -dd

Input Arguments

collapse all

Tick label format, specified as one of the following values.

FormatDescriptionExample
'dd'Decimal degrees plus compass direction
23.5°N
'dm'Degrees and decimal minutes plus compass direction
18°30'W
'dms' (default)Degrees, minutes, and decimal seconds plus compass direction
110°06'18.5"E
'-dd'Decimal degrees with a minus sign (-) to indicate south and west
-115.25°
'-dm'Degrees and decimal minutes with a minus sign (-) to indicate south and west
-5°45.5'
'-dms'Degrees, minutes, and decimal seconds with a minus sign (-) to indicate south and west
-3°21'05"

Data Types: char | string

Target geographic axes, specified as a GeographicAxes object.[1]

Tips

  • The value returned from geotickformat is the value of the TickLabelFormat property of the geographic axes. You can override this format value on an individual axis by setting the TickLabelFormat property of the GeographicRuler object associated with the axis. In this case, the value returned by geotickformat does not match the format value of the axis or the actual display. Setting the TickLabelFormat of an individual axis is not recommended.

Introduced in R2019a

[1] Alignment of boundaries and region labels are a presentation of the feature provided by the data vendors and do not imply endorsement by MathWorks®.