Main Content

GeographicScalebar Properties

Control appearance and behavior of geographic scale bar

Since R2019a

GeographicScalebarproperties control the appearance and behavior of theGeographicScalebarobject stored in aGeographicAxesorMapAxes(Mapping Toolbox™) object.

By changing property values, you can modify certain aspects of the scale bar. Access theGeographicScalebarobject using theScalebarproperty of theGeographicAxesorMapAxesobject. Use dot notation to query and set properties.

geoplot(1:10,1:10) gx = gca; v = gx.Scalebar.Visible; gx.Scalebar.Visible = "off";

Appearance

expand all

Background transparency, specified as a value in the range [0, 1]. A value of1means opaque and a value of0means transparent.

Example:gx.Scalebar.BackgroundAlpha = 0.2;

Background color, 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 from0toF. 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 Name Short Name RGB Triplet Hexadecimal Color Code Appearance
"red" "r" [10 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" [10 1] "#FF00FF"

Sample of the color magenta

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

Sample of the color yellow

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

Sample of the color black

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

Sample of the color white

"none" Not applicable Not applicable Not applicable No color

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

RGB Triplet Hexadecimal Color Code Appearance
[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

Example:gx.Scalebar.BackgroundColor = [0 0 1];

Example:gx.Scalebar.BackgroundColor = "b";

Example:gx.Scalebar.BackgroundColor = "none";

Example:gx.Scalebar.BackgroundColor = "#0000FF";

Line color, 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 from0toF. 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 Name Short Name RGB Triplet Hexadecimal Color Code Appearance
"red" "r" [10 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" [10 1] "#FF00FF"

Sample of the color magenta

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

Sample of the color yellow

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

Sample of the color black

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

Sample of the color white

"none" Not applicable Not applicable Not applicable No color

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

RGB Triplet Hexadecimal Color Code Appearance
[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 properties of the parent axes can affect the scale bar.

  • When the parent is a geographic axes, setting theAxisColorproperty for the axes sets theEdgeColorproperty for the scale bar to the same value.

  • When the parent is a map axes, setting theOutlineColorproperty for the axes sets theEdgeColorproperty for the scale bar to the same value.

However, setting properties of the scale bar does not affect the parent axes. To prevent the axes property value from overriding the scale bar property value, set the axes value first, and then set the scale bar value.

Example:gx.Scalebar.EdgeColor = "b";

Example:gx.Scalebar.EdgeColor = "blue";

Example:gx.Scalebar.EdgeColor = [0 0 1];

Example:gx.Scalebar.EdgeColor = "#0000FF";

Line width, specified as a positive value in point units. One point equals 1/72 inch.

Note

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

Example:gx.Scalebar.LineWidth = 2;

State of visibility, specified as'on'or'off', or as numeric or logical1(true) or0(false). A value of'on'相当于true, and'off'相当于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 typematlab.lang.OnOffSwitchState.

  • 'on'— Display the object.

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

Font

expand all

Font name, specified as a supported font name or'FixedWidth'. To display and print text properly, you must choose a font that your system supports. The default font depends on your operating system and locale.

To use a fixed-width font that looks good in any locale, use'FixedWidth'. The fixed-width font relies on the rootFixedWidthFontNameproperty. Setting the rootFixedWidthFontNameproperty causes an immediate update of the display to use the new font.

Note

Setting the字体名property for the parent axes sets the字体名property for the scale bar to the same value. However, setting the scale bar property does not set the axes property. To prevent the axes property value from overriding the scale bar property value, set the axes value first, and then set the scale bar value.

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

Font size, specified as a scalar numeric value.

Note

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

When using the font size stored in the parent axes, the scale bar scales the font size to 80% of the axes font size.

Example:gx.Scalebar.FontSize = 12;

Character thickness, specified as“正常”or'bold'.

MATLAB uses theFontWeightproperty to select a font from those 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 theFontWeightproperty for the parent axes sets theFontWeightproperty for the scale bar to the same value. However, setting the scale bar property does not set the axes property. To prevent the axes property value from overriding the scale bar property value, set the axes value first, and then set the scale bar value.

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

Font color, 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 from0toF. 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 Name Short Name RGB Triplet Hexadecimal Color Code Appearance
"red" "r" [10 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" [10 1] "#FF00FF"

Sample of the color magenta

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

Sample of the color yellow

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

Sample of the color black

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

Sample of the color white

"none" Not applicable Not applicable Not applicable No color

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

RGB Triplet Hexadecimal Color Code Appearance
[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 properties of the parent axes can affect the scale bar.

  • When the parent is a geographic axes, setting theAxisColorproperty for the axes sets theFontColorproperty for the scale bar to the same value.

  • When the parent is a map axes, setting theFontColorproperty for the axes sets theFontColorproperty for the scale bar to the same value.

However, setting properties of the scale bar does not affect the parent axes. To prevent the axes property value from overriding the scale bar property value, set the axes value first, and then set the scale bar value.

Example:gx.Scalebar.FontColor = "b";

Example:gx.Scalebar.FontColor = "blue";

Example:gx.Scalebar.FontColor = [0 0 1];

Example:gx.Scalebar.FontColor = "#0000FF";

Character slant, specified as“正常”or'italic'.

Not all fonts have both font styles. Therefore, the italic font might look the same as the normal font.

Note

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

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

Font smoothing, specified as'on'or'off', or as numeric or logical1(true) or0(false). A value of'on'相当于true, and'off'相当于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 typematlab.lang.OnOffSwitchState.

  • 'on'— Use antialiasing to make text appear smoother on the screen.

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

Note

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

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

Parent/Child

expand all

This property is read-only.

Parent, specified as aGeographicAxesobject orMapAxesobject.

Note

Scale bar objects are not listed in theChildrenproperty of the parent object.

This property is read-only.

Scale bar objects have no children.

版本历史

Introduced in R2019a

expand all

See Also

Properties