πŸ“ Scalebars

A scalebar can be added to a map via Maps.add_scalebar().

  • By default, the scalebar will dynamically estimate an appropriate scale and position based on the currently visible map extent.

    • To change the number of segments for the scalebar, use s = m.add_scalebar(n=5) or s.set_n(5)

    • To set the length of the segments to a fixed distance, use s = m.add_scalebar(scale=1000) or s.set_scale(1000)

    • To fix the position of the scalebar, use s = m.add_scalebar(pos=(20, 40)) or s.set_position(20, 40)

In addition, many style properties of the scalebar can be adjusted to get the look you want.

  • check the associated setter-functions ScaleBar.set_< label / scale / lines / labels >_props below!

Maps.add_scalebar

Add a scalebar to the map.

from eomaps import Maps
m = Maps(Maps.CRS.Sinusoidal())
m.add_feature.preset.ocean()
s = m.add_scalebar()
_images/scalebar.gif

Interacting with the scalebar

The scalebar is a pickable object!

Click on it with the LEFT mouse button to drag it around, and use the RIGHT mouse button (or press escape) to make it fixed again.

If the scalebar is picked (indicated by a red border), you can use the following functionalities to adjust some of the ScaleBar properties:

  • use the scroll-wheel to adjust the auto-scale of the scalebar (hold down shift for larger steps)

  • use control + scroll-wheel to adjust the size of the labels

  • press delete to remove the scalebar from the plot

  • press + or - to rotate the scalebar

  • press up/down/left/right to increase the size of the frame

  • press alt + up/down/left/right: decrease the size of the frame

  • press control + left/right: to increase / decrease the spacing between labels and scale

  • press control + up/down: to rotate the labels

Note: Once you have created a nice scalebar, you can always use s.print_code() to get an executable code that will reproduce the current appearance of the scalebar.

The returned ScaleBar object provides the following useful methods:

ScaleBar

Base class for EOmaps scalebars.

ScaleBar.print_code

Print the command that will reproduce the scalebar in its current state.

ScaleBar.apply_preset

Apply a style-preset to the Scalebar.

ScaleBar.remove

Remove the scalebar from the map.

ScaleBar.set_scale

Set the length of a segment of the scalebar in meters.

ScaleBar.set_n

Set number of segments to use for the scalebar.

ScaleBar.set_position

Set the position of the colorbar.

ScaleBar.set_label_props

Set the style properties of the labels.

ScaleBar.set_scale_props

Set the style properties of the scale.

ScaleBar.set_line_props

Set the style properties of the lines connecting the scale and the labels.

ScaleBar.set_patch_props

Set the style properties of the background patch.

ScaleBar.set_auto_scale

Automatically evaluate an appropriate scale for the scalebar.

ScaleBar.set_pickable

Set if the scalebar is interactive (True) or not (False).

ScaleBar.set_size_factor

Set the size_factor that is used to adjust the size of the labels.

ScaleBar.get_position

Return the current position (and orientation) of the scalebar.

ScaleBar.get_scale

Get the currently used scale of the scalebar.

ScaleBar.get_size_factor

Get the current size-factor of the scalebar.