add_scalebar

Maps.add_scalebar(m, preset=None, scale=None, autoscale_fraction=0.25, auto_position=(0.75, 0.25), scale_props=None, patch_props=None, label_props=None)

Add a scalebar to the map. The scalebar represents a ruler in units of meters whose direction follows geodesic lines.

Note

You can click on the scalebar to dynamically adjust its position, orientation and size! (hold down the left mouse-button to use the keys)

  • < LEFT-click> on the scalebar to make the scalebar interactive

  • you can move and interact with the scalebar as long as you hold down the < LEFT > mouse-button

  • use < + > and < - > keys on your keyboard to rotate the scalebar

  • use <alt> + < + > and < - > keys to set the text-offset

  • use the < arrow-keys > to increase the size of the frame

  • use < alt > + < arrow-keys > to decrease the size of the frame

  • use the < DELETE-key > to remove the scalebar from the plot

Parameters
  • lon (float) – The longitude and latitude of the starting point for the scalebar (If None, the center of the axis is used )

  • lat (float) – The longitude and latitude of the starting point for the scalebar (If None, the center of the axis is used )

  • azim (float) – The azimuth-direction (in degrees) in which the scalebar points. The default is 90.

  • preset (str) –

    The name of the style preset to use.

    • ”bw” : a simple black-and white ruler without a background patch

  • scale (float or None, optional) –

    The distance of the individual segments of the scalebar.

    • If None: the scale is automatically updated based on the current zoom level and the provided “autoscale_fraction”.

    • If float: A fixed length of the segments (in meters). (e.g. the total length of the scalebar will be scale_props[“n”] * scale

    The default is None.

  • autoscale_fraction (float, optional) – The (approximate) fraction of the axis width to use as size for the scalebar in the autoscale procedure. Note that this is number is not exact since (depending on the crs) the final scalebar might be curved. The default is 0.25.

  • auto_position (tuple or False, optional) –

    Re-position the scalebar automatically on pan/zoom events.

    • If False: the position of the scalebar remains fixed.

    • If a tuple is provided, it is identified as relative (x, y) position on the axes (e.g. (0,0)=lower left, (1,1)=upper right )

    The default is (0.75, 0.25).

  • scale_props (dict, optional) –

    A dictionary that is used to set the properties of the scale.

    • ”n”: (int) The number of scales (e.g. line-segments) to draw.

    • ”width”: (float) The width of the scalebar

    • ”colors” (tuple): A sequence of colors that will be repeated to color the individual line-fragments of the scalebar. (you can provide more than 2 colors!) The default is (“k”, “w”).

    The default is:
    >>> dict(n=10, width=5, colors=("k", "w"))
    

  • patch_props (dict, optional) –

    A dictionary that is used to set the properties of the frame-patch.

    • ”offsets”: A tuple that is used to adjust the offset of the frame-patch. Individual values represent (top, bottom, left, right) on a horizontally oriented scalebar. The default is (1, 1, 1, 1).

    • … additional kwargs are passed to the PolygonPatch used to draw the frame. Possible values are:

    • ”facecolor”, “edgecolor”, “linewidth”, “linestyle”, “alpha” …

    The default is:
    >>> dict(fc=".75", ec="k", lw=1)
    

  • label_props (dict, optional) –

    A dictionary that is used to set the properties of the labels.

    • ”scale”: A scaling factor for the fontsize

    • ”offset” : A scaling factor to adjust the offset of the labels relative to the scalebar

    • ”rotation” : the rotation angle of the labels (in degrees) relative to the curvature of the scalebar

    • ”color” : The color of the text

    • ”every” : indicator which scales should be labelled (e.g. every nth)

    • … additional kwargs are passed to matplotlib.font_manager.FontProperties to set the used font-properties. Possible values are:

      • ”family”, “style”, “variant”, “stretch”, and “weight”

      for example: {family=”Helvetica”, style=”italic”}

    The default is:
    >>> dict(scale=1, offset=1, rotation=0, every=2)