@@ -510,7 +510,7 @@ def cb(*args, **kwargs):
510510 if _log .getEffectiveLevel () <= 10 :
511511 logmsg = (
512512 f"Adding { 'persistent' if persistent else 'single-shot' } "
513- f"layer change action for: '{ layer } ' "
513+ f"layer change action for: '{ layer if layer else 'all layers' } ': { getattr ( func , '__qualname__' , func ) } "
514514 )
515515 _log .debug (logmsg )
516516
@@ -903,14 +903,14 @@ def _on_draw_cb(self, event):
903903 if loglevel <= 5 :
904904 _log .log (5 , "There was an error during draw!" , exc_info = True )
905905
906- def add_artist (self , art , layer = None ):
906+ def add_artist (self , * artists , layer = None ):
907907 """
908908 Add a dynamic-artist to be managed.
909909 (Dynamic artists are re-drawn on every update!)
910910
911911 Parameters
912912 ----------
913- art : Artist
913+ artists : Artist
914914
915915 The artist to be added. Will be set to 'animated' (just
916916 to be safe). *art* must be in the figure associated with
@@ -922,38 +922,38 @@ def add_artist(self, art, layer=None):
922922
923923 The default is None in which case the layer of the base-Maps object is used.
924924 """
925-
926- if art .figure != self .figure :
927- raise RuntimeError (
928- "EOmaps: The artist does not belong to the figure"
929- "of this Maps-object!"
930- )
931-
932925 if layer is None :
933926 layer = self ._m .layer
934927
935928 # make sure all layers are converted to string
936929 layer = str (layer )
937930
938- self ._artists .setdefault (layer , list ())
931+ for art in artists :
932+ if art .figure != self .figure :
933+ raise RuntimeError (
934+ "EOmaps: The artist does not belong to the figure"
935+ "of this Maps-object!"
936+ )
939937
940- if art in self ._artists [layer ]:
941- return
942- else :
943- art .set_animated (True )
944- self ._artists [layer ].append (art )
938+ self ._artists .setdefault (layer , list ())
945939
946- if isinstance (art , plt .Axes ):
947- self ._managed_axes .add (art )
940+ if art in self ._artists [layer ]:
941+ continue
942+ else :
943+ art .set_animated (True )
944+ self ._artists [layer ].append (art )
948945
949- def add_bg_artist (self , art , layer = None , draw = True ):
946+ if isinstance (art , plt .Axes ):
947+ self ._managed_axes .add (art )
948+
949+ def add_bg_artist (self , * artists , layer = None , draw = True ):
950950 """
951951 Add a background-artist to be managed.
952952 (Background artists are only updated on zoom-events... they are NOT animated!)
953953
954954 Parameters
955955 ----------
956- art : Artist
956+ artists : Artist
957957 The artist to be added. Will be set to 'animated' (just
958958 to be safe). *art* must be in the figure associated with
959959 the canvas this class is managing.
@@ -974,31 +974,32 @@ def add_bg_artist(self, art, layer=None, draw=True):
974974 # make sure all layer names are converted to string
975975 layer = str (layer )
976976
977- if art .figure != self .figure :
978- raise RuntimeError
977+ for art in artists :
978+ if art .figure != self .figure :
979+ raise RuntimeError
979980
980- # put all artist of inset-maps on dedicated layers
981- if (
982- getattr (art , "axes" , None ) is not None
983- and art .axes .get_label () == "inset_map"
984- and not layer .startswith ("__inset_" )
985- ):
986- layer = "__inset_" + str (layer )
981+ # put all artist of inset-maps on dedicated layers
982+ if (
983+ getattr (art , "axes" , None ) is not None
984+ and art .axes .get_label () == "inset_map"
985+ and not layer .startswith ("__inset_" )
986+ ):
987+ layer = "__inset_" + str (layer )
987988
988- if layer in self ._bg_artists and art in self ._bg_artists [layer ]:
989- _log .info (
990- f"EOmaps: Background-artist '{ art } ' already added on layer '{ layer } '"
991- )
992- return
989+ if layer in self ._bg_artists and art in self ._bg_artists [layer ]:
990+ _log .info (
991+ f"EOmaps: Background-artist '{ art } ' already added on layer '{ layer } '"
992+ )
993+ continue
993994
994- art .set_animated (True )
995- self ._bg_artists .setdefault (layer , []).append (art )
995+ art .set_animated (True )
996+ self ._bg_artists .setdefault (layer , []).append (art )
996997
997- if isinstance (art , plt .Axes ):
998- self ._managed_axes .add (art )
998+ if isinstance (art , plt .Axes ):
999+ self ._managed_axes .add (art )
9991000
1000- # tag all relevant layers for refetch
1001- self ._refetch_layer (layer )
1001+ # tag all relevant layers for refetch
1002+ self ._refetch_layer (layer )
10021003
10031004 for f in self ._on_add_bg_artist :
10041005 f ()
0 commit comments