@@ -407,6 +407,88 @@ def scatter_timeline(
407407 mappables ["scatter" ] = ax .scatter (self .time , y , ** kwargs )
408408 return mappables
409409
410+ def event_map (self , ax , ** kwargs ):
411+ """Add the merging and splitting events """
412+ j = 0
413+ mappables = dict ()
414+ symbol_kw = dict (
415+ markersize = 10 ,
416+ color = "k" ,
417+ )
418+ symbol_kw .update (kwargs )
419+ symbol_kw_split = symbol_kw .copy ()
420+ symbol_kw_split ["markersize" ] += 5
421+ for i , b0 , b1 in self .iter_on ("segment" ):
422+ nb = i .stop - i .start
423+ if nb == 0 :
424+ continue
425+ event_kw = dict (color = self .COLORS [j % self .NB_COLORS ], ls = "-" , ** kwargs )
426+ i_n , i_p = (
427+ self .next_obs [i .stop - 1 ],
428+ self .previous_obs [i .start ],
429+ )
430+
431+ if i_n != - 1 :
432+ y0 , y1 = self .lat [i .stop - 1 ], self .lat [i_n ]
433+ x0 , x1 = self .lon [i .stop - 1 ], self .lon [i_n ]
434+ ax .plot ((x0 , x1 ), (y0 , y1 ), ** event_kw )[0 ]
435+ ax .plot (x0 , y0 , marker = "s" , ** symbol_kw )[0 ]
436+ if i_p != - 1 :
437+ y0 , y1 = self .lat [i .start ], self .lat [i_p ]
438+ x0 , x1 = self .lon [i .start ], self .lon [i_p ]
439+ ax .plot ((x0 , x1 ), (y0 , y1 ), ** event_kw )[0 ]
440+ ax .plot (x0 , y0 , marker = "*" , ** symbol_kw_split )[0 ]
441+
442+ j += 1
443+ return mappables
444+
445+ def scatter (
446+ self ,
447+ ax ,
448+ name = "time" ,
449+ factor = 1 ,
450+ ref = None ,
451+ edgecolor_cycle = None ,
452+ ** kwargs ,
453+ ):
454+ """
455+ This function will scatter the path of each network, with the merging and splitting events
456+
457+ :param matplotlib.axes.Axes ax: matplotlib axe used to draw
458+ :param str,array,None name:
459+ variable used to fill the contour, if None all elements have the same color
460+ :param float,None ref: if define use like west bound
461+ :param float factor: multiply value by
462+ :param list edgecolor_cycle: list of colors
463+ :param dict kwargs: look at :py:meth:`matplotlib.axes.Axes.scatter`
464+ :return: a dict of scattered mappables
465+ """
466+ mappables = dict ()
467+ nb_colors = len (edgecolor_cycle ) if edgecolor_cycle else None
468+ x = self .longitude
469+ if ref is not None :
470+ x = (x - ref ) % 360 + ref
471+ kwargs = kwargs .copy ()
472+ if nb_colors :
473+ edgecolors = list ()
474+ seg_previous = self .segment [0 ]
475+ j = 0
476+ for seg in self .segment :
477+ if seg != seg_previous :
478+ j += 1
479+ edgecolors .append (edgecolor_cycle [j % nb_colors ])
480+ seg_previous = seg
481+ mappables ["edges" ] = ax .scatter (
482+ x , self .latitude , edgecolor = edgecolors , ** kwargs
483+ )
484+ kwargs .pop ("linewidths" , None )
485+ kwargs ["lw" ] = 0
486+ if name is not None and "c" not in kwargs :
487+ v = self .parse_varname (name )
488+ kwargs ["c" ] = v * factor
489+ mappables ["scatter" ] = ax .scatter (x , self .latitude , ** kwargs )
490+ return mappables
491+
410492 def insert_virtual (self ):
411493 # TODO
412494 pass
0 commit comments