Main Content

GeographicRuler Properties

Control axis with geographic values

Since R2019a

GeographicRuler properties control the appearance and behavior of the latitude axis and longitude axis in a GeographicAxes object. Each individual axis has its own ruler object. By changing property values of the ruler, you can modify certain aspects of a specific axis.

You can customize some aspects of the rulers by setting properties of the geographic axes instead of setting properties of the rulers. For example, you can specify a different color for each ruler by setting the Color property of each GeographicRuler object. However, by setting the AxisColor property of the GeographicAxes object, you can keep the appearance of the rulers consistent.

Use dot notation to refer to a particular ruler and property. Access the ruler objects through the LatitudeAxis or LongitudeAxis properties of the GeographicAxes object.

geoplot(1:10,1:10)
gx = gca;
co = gx.LatitudeAxis.Color;
gx.LatitudeAxis.Color = "blue";

Appearance

expand all

This property is read-only.

Minimum and maximum axis limits, returned as a two-element vector of the form [min max].

To set the limits of a GeographicAxes object, use the geolimits function.

Note

The values of the Limits properties for the latitude and longitude axes match the values of the LatitudeLimits and LongitudeLimits properties of the parent GeographicAxes object, respectively.

Example: latlim = gx.LatitudeAxis.Limits;

Color of the axis line and labels, specified as an RGB triplet, a hexadecimal color code, a color name, or a short color name.

For a custom color, specify an RGB triplet or a hexadecimal color code.

  • An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1], for example, [0.4 0.6 0.7].

  • A hexadecimal color code is a string scalar or character vector that starts with a hash symbol (#) followed by three or six hexadecimal digits, which can range from 0 to F. The values are not case sensitive. Therefore, the color codes "#FF8800", "#ff8800", "#F80", and "#f80" are equivalent.

Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.

Color NameShort NameRGB TripletHexadecimal Color CodeAppearance
"red""r"[1 0 0]"#FF0000"

Sample of the color red

"green""g"[0 1 0]"#00FF00"

Sample of the color green

"blue""b"[0 0 1]"#0000FF"

Sample of the color blue

"cyan" "c"[0 1 1]"#00FFFF"

Sample of the color cyan

"magenta""m"[1 0 1]"#FF00FF"

Sample of the color magenta

"yellow""y"[1 1 0]"#FFFF00"

Sample of the color yellow

"black""k"[0 0 0]"#000000"

Sample of the color black

"white""w"[1 1 1]"#FFFFFF"

Sample of the color white

"none"Not applicableNot applicableNot applicableNo color

Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB® uses in many types of plots.

RGB TripletHexadecimal Color CodeAppearance
[0 0.4470 0.7410]"#0072BD"

Sample of RGB triplet [0 0.4470 0.7410], which appears as dark blue

[0.8500 0.3250 0.0980]"#D95319"

Sample of RGB triplet [0.8500 0.3250 0.0980], which appears as dark orange

[0.9290 0.6940 0.1250]"#EDB120"

Sample of RGB triplet [0.9290 0.6940 0.1250], which appears as dark yellow

[0.4940 0.1840 0.5560]"#7E2F8E"

Sample of RGB triplet [0.4940 0.1840 0.5560], which appears as dark purple

[0.4660 0.6740 0.1880]"#77AC30"

Sample of RGB triplet [0.4660 0.6740 0.1880], which appears as medium green

[0.3010 0.7450 0.9330]"#4DBEEE"

Sample of RGB triplet [0.3010 0.7450 0.9330], which appears as light blue

[0.6350 0.0780 0.1840]"#A2142F"

Sample of RGB triplet [0.6350 0.0780 0.1840], which appears as dark red

Note

Setting the AxisColor property for the parent axes sets the Color properties for the ruler objects to the same value. However, setting properties of the rulers does not affect the parent axes. To prevent the axes property value from overriding the ruler property values, set the axes value first, and then set the ruler values.

Example: gx.LatitudeAxis.Color = "b"

Example: gx.LatitudeAxis.Color = "blue"

Example: gx.LatitudeAxis.Color = [0.1 0.7 0.8];

Example: gx.LatitudeAxis.Color = "#0000FF";

Width of axis line and tick marks, specified as a positive value in point units. One point equals 1/72 inch.

Note

Setting the LineWidth property for the parent axes sets the LineWidth properties for the ruler objects to the same value. However, setting properties of the rulers does not affect the parent axes. To prevent the axes property value from overriding the ruler property values, set the axes value first, and then set the ruler values.

Example: gx.LatitudeAxis.LineWidth = 2;

Axis label, specified as a Text object.

To change existing text, set the String property of the Text object. Use other properties to change the text appearance, such as the font size or color.

This code shows how to change the text of the latitude axis label to "Latitude Axis" and the font size of the longitude axis label to 16.

gx = geoaxes;
gx.LatitudeAxis.Label.String = "Latitude Axis";
gx.LongitudeAxis.Label.FontSize = 16;

For a full list of options, see Text Properties.

Geographic axes with customized latitude and longitude axis labels. The latitude axis label has updated text and the longitude axis label is larger.

Note

  • The text object is not a child of the ruler object, so it cannot be returned by findobj and it does not use default text property values.

  • The text object stored in this property is the same as the text object stored in the parent object's label property. Thus, you can modify the text object using either the ruler or the parent object's property. For example, setting the font size on a text object stored in a latitude axis ruler's Label property is the same as setting the font size on the text object stored in the LatitudeLabel property of the parent axes.

Axis label horizontal alignment, specified as one of the values from the table.

LabelHorizontalAlignment ValueDescriptionAppearance
'center'

For a horizontal axis, the label is centered between the left and right edges of the plot box.

For a vertical axis, the label is centered between the top and bottom edges of the plot box.

Horizontal and a vertical axis labels that are centered.

'left'

For a horizontal axis, the label is aligned with the left edge of the plot box.

For a vertical axis, the label is aligned with the bottom edge of the plot box.

Horizontal and a vertical axis labels that left-aligned.

'right'

For a horizontal axis, the label is aligned with the right edge of the plot box.

For a vertical axis, the label is aligned with the top edge of the plot box.

Horizontal and a vertical axis labels that right-aligned.

Axis ruler visibility, specified as 'on' or 'off', or as numeric or logical 1 (true) or 0 (false). A value of 'on' is equivalent to true, and 'off' is equivalent to false. Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState.

  • 'on' — Display the axis ruler.

  • 'off' — Hide the axis ruler without deleting it. You still can access properties of an invisible axis ruler using the ruler object.

Example: gx.LatitudeAxis.Visible = "off";

Tick Values and Labels

expand all

Tick mark locations along the axis, specified as a vector of increasing values.

If you assign a value to this property, MATLAB sets the TickValuesMode property to 'manual'.

Example: gx.LatitudeAxis.TickValues = [-15 -10 0 10 15];

Example: gx.LongitudeAxis.TickValues = 0:10:100;

Selection mode for the TickValues property, specified as one of these values:

  • 'auto' — Automatically select the tick values based on the limits of the map and the position (size) of the axes.

  • 'manual' — Use tick values that you specify. To specify the values, set the TickValues property.

Tick mark labels, specified as a cell array of character vectors or a string array. If you do not specify enough labels for all of the tick values, then the labels repeat. The labels support TeX and LaTeX markup. See the TickLabelInterpreter property for more information.

Example: gx.TickValues = [-66.5 -23.5 0 23.5 66.5];

Example: gx.LatitudeAxis.TickLabels = {'Antarctic Circle','Tropic of Capricorn','Equator','Tropic of Cancer','Arctic Circle'};

If you set this property, MATLAB sets the TickLabelsMode property to 'manual'.

Data Types: char | string

Selection mode for the TickLabels property, specified as one of these values:

  • 'auto' — Automatically select the tick labels.

  • 'manual' — Use tick labels that you specify. To specify the labels, set the TickLabels property.

Tick label color, specified as an RGB triplet, a hexadecimal color code, a color name, or a short name.

For a custom color, specify an RGB triplet or a hexadecimal color code.

  • An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1], for example, [0.4 0.6 0.7].

  • A hexadecimal color code is a string scalar or character vector that starts with a hash symbol (#) followed by three or six hexadecimal digits, which can range from 0 to F. The values are not case sensitive. Therefore, the color codes "#FF8800", "#ff8800", "#F80", and "#f80" are equivalent.

Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.

Color NameShort NameRGB TripletHexadecimal Color CodeAppearance
"red""r"[1 0 0]"#FF0000"

Sample of the color red

"green""g"[0 1 0]"#00FF00"

Sample of the color green

"blue""b"[0 0 1]"#0000FF"

Sample of the color blue

"cyan" "c"[0 1 1]"#00FFFF"

Sample of the color cyan

"magenta""m"[1 0 1]"#FF00FF"

Sample of the color magenta

"yellow""y"[1 1 0]"#FFFF00"

Sample of the color yellow

"black""k"[0 0 0]"#000000"

Sample of the color black

"white""w"[1 1 1]"#FFFFFF"

Sample of the color white

"none"Not applicableNot applicableNot applicableNo color

Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.

RGB TripletHexadecimal Color CodeAppearance
[0 0.4470 0.7410]"#0072BD"

Sample of RGB triplet [0 0.4470 0.7410], which appears as dark blue

[0.8500 0.3250 0.0980]"#D95319"

Sample of RGB triplet [0.8500 0.3250 0.0980], which appears as dark orange

[0.9290 0.6940 0.1250]"#EDB120"

Sample of RGB triplet [0.9290 0.6940 0.1250], which appears as dark yellow

[0.4940 0.1840 0.5560]"#7E2F8E"

Sample of RGB triplet [0.4940 0.1840 0.5560], which appears as dark purple

[0.4660 0.6740 0.1880]"#77AC30"

Sample of RGB triplet [0.4660 0.6740 0.1880], which appears as medium green

[0.3010 0.7450 0.9330]"#4DBEEE"

Sample of RGB triplet [0.3010 0.7450 0.9330], which appears as light blue

[0.6350 0.0780 0.1840]"#A2142F"

Sample of RGB triplet [0.6350 0.0780 0.1840], which appears as dark red

Note

Setting the ruler’s Color property also sets the TickLabelColor property to the same value. However, setting the TickLabelColor property does not change the Color property. To prevent the Color property value from overriding the TickLabelColor property value, set the Color property first, and then set the TickLabelColor property.

Interpretation of tick label characters, specified as one of these values:

  • 'tex' — Interpret characters using a subset of TeX markup.

  • 'latex' — Interpret characters using LaTeX markup.

  • 'none' — Display literal characters.

For more information about these interpreters, see the Interpreter property on the Text Properties reference page.

Example: gx.LatitudeAxis.TickLabelInterpreter = 'latex';

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

FormatDescriptionExample
"dd"Decimal degrees plus compass direction23°N
"dm"Degrees and decimal minutes plus compass direction18°30'W
"dms" (default)Degrees, minutes, and decimal seconds plus compass direction110°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"

You can also specify the tick label format using the geotickformat function.

Note

Setting the TickLabelFormat property for the parent axes sets the TickLabelFormat properties for the ruler objects to the same value. However, setting properties of the rulers does not affect the parent axes. To prevent the axes property value from overriding the ruler property values, set the axes value first, and then set the ruler values.

Example: gx.LatitudeAxis.TickLabelFormat = "dd";

Rotation of the tick labels, specified as a scalar value in degrees. Positive values give counterclockwise rotation. Negative values give clockwise rotation.

Sample rotated tick label

If you assign a value to this property, then MATLAB sets the TickLabelRotation property to 'manual'.

Example: gx.LatitudeAxis.TickLabelRotation = -45;

Example: gx.LongitudeAxis.TickLabelRotation = 45;

Selection mode for the TickLabelRotation property, specified as one of these values:

  • 'auto' — Object automatically selects the tick label rotation.

  • 'manual' — Use a tick label rotation that you specify. To specify the rotation, set the TickLabelRotation property.

Tick mark direction, specified as one of these values:

  • 'in' — Direct the tick marks inward from the axis lines. This is the default for 2-D views.

  • 'out' — Direct the tick marks outward from the axis lines. This is the default for 3-D views.

  • 'both' — Center the tick marks over the axis lines.

  • 'none' — Do not display any tick marks.

If you assign a value to this property, then MATLAB sets the TickDirectionMode property to 'manual'.

Note

Setting the TickDir property for the parent axes sets the TickDirection property for the ruler to the same value. However, setting the ruler property does not set the axes property. To prevent the axes property value from overriding the ruler property value, set the axes value first, and then set the ruler value.

Selection mode for the TickDirection property, specified as one of these values:

  • 'auto' — Automatically select the tick direction.

  • 'manual' — Use a tick direction that you specify. To specify the tick direction, set the TickDirection property.

Tick mark length, specified as a two-element vector of the form [length unused]. The first element is the tick mark length. The second element is unused by the geographic ruler, but is included for consistency with other ruler objects. Specify the values in units normalized relative to the longest axes dimension.

Note

Setting the TickLength property for the parent axes sets the TickLength properties for the ruler objects to the same value. However, setting properties of the rulers does not affect the parent axes. To prevent the axes property value from overriding the ruler property values, set the axes value first, and then set the ruler values.

Example: gx.LatitudeAxis.TickLength = [0.04 0];

Font

expand all

Font name, specified as a system supported font name or 'FixedWidth'. The default font depends on the specific system and locale. To use a fixed-width font that looks good in any locale, specify 'FixedWidth'. The actual fixed-width font used depends on the FixedWidthFontName property of the root object.

Note

Setting the FontName property for the parent axes sets the FontName properties for the ruler objects to the same value. However, setting properties of the rulers does not affect the parent axes. To prevent the axes property value from overriding the ruler property values, set the axes value first, and then set the ruler values.

Example: gx.LatitudeAxis.FontName = "Cambria";

Font size, specified as a scalar numeric value. The default font size depends on the specific operating system and locale.

Note

  • Setting the FontSize property for the parent axes sets the FontSize properties for the rulers to the same value. However, setting the ruler properties does not set the axes property. To prevent the axes property value from overriding the ruler property values, set the axes value first, and then set the ruler values.

  • Setting the FontSize property on the ruler changes the size of the tick labels. MATLAB also updates the font size of the corresponding axes label using the LabelFontSizeMultiplier of the parent axes. For example, setting the font size of a latitude axis ruler to 12 sets the font size for the LatitudeLabel property of the parent axes to 12 times the value of the LabelFontSizeMultiplier property.

Example: gx.LatitudeAxis.FontSize = 12;

Thickness of the text characters, specified as one of these values:

  • 'normal' — Default weight as defined by the particular font.

  • 'bold' — Thicker character outlines than normal.

MATLAB uses the FontWeight property to select a font from the fonts available on your system. Not all fonts have a bold font weight. Therefore, specifying a bold font weight still can result in the normal font weight.

Note

Setting the FontWeight property for the parent axes sets the FontWeight properties for the ruler objects to the same value. However, setting properties of the rulers does not affect the parent axes. To prevent the axes property value from overriding the ruler property values, set the axes value first, and then set the ruler values.

Example: gx.LatitudeAxis.FontWeight = "bold";

Character slant, specified as 'normal' or 'italic'. Not all fonts have both font styles. Therefore, the italic font can look the same as the normal font.

Note

Setting the FontAngle property for the parent axes sets the FontAngle properties for the ruler objects to the same value. However, setting properties of the rulers does not affect the parent axes. To prevent the axes property value from overriding the ruler property values, set the axes value first, and then set the ruler values.

Example: gx.LatitudeAxis.FontAngle = "italic";

Character smoothing, specified as 'on' or 'off', or as numeric or logical 1 (true) or 0 (false). A value of 'on' is equivalent to true, and 'off' is equivalent to false. Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState.

  • 'on' — Use antialiasing to reduce the jagged appearance of text characters and make the text easier to read. In certain cases, smoothed text blends against the background color and can make the text appear blurry.

  • 'off' — Do not use antialiasing. Use this setting if the text seems blurry.

Example: gx.LatitudeAxis.FontSmoothing = "off";

Note

The FontSmoothing property will have no effect in a future release. Font smoothing will be enabled regardless of the value of the property.

Callbacks

expand all

Axis limits changed callback, specified as one of these values:

  • A function handle.

  • A cell array in which the first element is a function handle. Subsequent elements in the cell array are the arguments to pass to the callback function.

  • A character vector containing a valid MATLAB expression (not recommended). MATLAB evaluates this expression in the base workspace.

This callback executes after the axis limits have changed, either programmatically or using an interaction such as panning within the axes. It can also execute if MATLAB changes the axis limits to encompass the range of your data when you call a plotting function.

This callback function can access specific information about the axis limits. MATLAB passes this information in a LimitsChanged object as the second argument to your callback function. If you are developing an app in App Designer, the argument is called event. You can query the object properties using dot notation. For example, event.NewLimits returns the new axis limits. The LimitsChanged object is not available to callback functions specified as character vectors.

The following table lists the properties of the LimitsChanged object.

Property

Description

Source

Ruler object that executes the callback

EventName

'LimitsChanged'

OldLimits

Two-element vector containing the previous axis limits

NewLimits

Two-element vector containing the new axis limits

For more information about writing callbacks in apps, see Callbacks in App Designer.

Parent/Child

expand all

Ruler parent, specified as a GeographicAxes object.

Note

Ruler objects are not listed in the Children property of the parent GeographicAxes object.

The ruler has no children. You cannot set this property.

Version History

Introduced in R2019a

expand all