EOmaps
v7.3.3

General

  • πŸ› Installation
  • πŸ‘€ FAQ

How to use EOmaps

  • 🌱 Basics
  • πŸ”΄ Data Visualization

Map Features

  • πŸ”¬ Inset Maps
  • 🌡 NaturalEarth features
  • πŸ›° WebMap layers
  • πŸ’  Vector Data
  • πŸ• Annotations, Markers, Logos, etc.
  • πŸ“ Scalebars
  • 🧭 Compass (or North Arrow)
  • β–¦ Gridlines

Interactivity

  • πŸ›Έ Callbacks
  • 🧰 Companion Widget
  • πŸ—οΈ Layout Editor
  • ✏️ Draw shapes on the map
  • πŸ”¦ Utilities

Miscellaneous

  • πŸ“¦ Reading data
  • β›­ Command Line Interface
  • πŸ“šLogging
  • πŸ”Έ Miscellaneous

Examples

  • πŸ—Ί EOmaps examples

Contribute

  • πŸš€ Contribution Guide

API Reference

  • eomaps
    • set_loglevel
    • annotation_editor
      • AnnotationEditor
        • AnnotationEditor
        • __init__
        • emit_edit_signal
        • emit_selected_signal
        • print_code
        • remove_info_text
        • remove_selected_annotation
        • set_info
        • show_info_text
        • toggle_info_text
        • update_selected_text
        • update_text
        • annotations
      • DraggableAnnotation
      • DraggableBase
    • callbacks
    • cb_container
    • colorbar
    • compass
    • draw
    • eomaps
    • grid
    • helpers
    • inset_maps
    • mapsgrid
    • ne_features
    • projections
    • reader
    • scalebar
    • scripts
    • shapes
    • webmap_containers
EOmaps
  • <no title>
  • eomaps
  • annotation_editor
  • AnnotationEditor
  • print_code
  • Edit on GitHub

print_code

AnnotationEditor.print_code(m_name='m', what='all', sanitize_coordinates=True, replace=None, use_ids=False)

Print the code to reproduce the annotations to the console.

Note

While this works nicely in most standard cases, it can not be guaranteed that extensively customized annotations are properly translated to code!

Text-functions that are used to dynamically update the annotation-text will be replaced by the currently visible text! To maintain interactivity, you can replace individual arguments via the replace dict.

If coordinates are provided in a custom crs, they will be reprojected to epsg=4326 to avoid issues with incorrect string-representations of the crs and to make the annotation independent of the current map-crs (in case xy_crs=None).

Parameters:
  • m_name (str, optional) – The variable-name of the Maps-object used in the code. (code will be generated as < m_name >.add_annotation(…)) The default is β€œm”.

  • what (str, int or list of int, optional) –

    Indicator which annotation codes should be printed.

    • if β€œall”: the code for all annotations is printed

    • if int: only the code for the nth annotation is printed

    • if list of int: the code for the annotations [0,.., i, .., n] is printed

    The default is β€œall”.

  • sanitize_coordinates (bool, optional) –

    If Tue, annotation coordinates where the crs has not been specified explicitly are reprojected to epsg=4326 to avoid amiguities (e.g. if the plot-crs changes etc.)

    If False, coordinates will be returned as-is (which might lead to incorrect results in some cases). The default is True

  • replace (dict or None, optional) –

    A dictionary of values used to replace the arguments of the annotation-call. This is particularly useful if you want to keep annotations interactive, for example if you use a function to set the text, you can use the following to maintain the function in the printed text:

    >>> my_textfunc = lambda ID, **kwargs: str(ID)
    >>> m._edit_annotations.print_code(replace={"text": my_textfunc})
    

  • use_ids (bool, optional) –

    If True, ID values are used to identify the annotation-positions. (NOTE: this can cause problems because the Maps-object must have

    the correct data assigned to identify the annotation!)

    If False, always use the current position of the annotation as input-argument for the returned code.

Previous Next

© Copyright . Revision ab2452db.

Built with Sphinx using a theme provided by Read the Docs.