1- from abc import ABC , ABCMeta
2- from dataclasses import dataclass , field , asdict , fields
3- from typing import Tuple , Literal , Dict , Any , Union , Iterator
1+ from abc import ABC
42from copy import deepcopy
5- from ._misc import ColorGenerator , MarkerShapeGenerator
3+ from dataclasses import asdict , dataclass , field , fields
4+ from typing import Any , Dict , Iterator , Literal , Tuple , Union
5+
66import pandas as pd
77
8+ from ._misc import ColorGenerator , MarkerShapeGenerator
9+
810
911@dataclass (kw_only = True )
1012class BaseConfig (ABC ):
11-
1213 @classmethod
1314 def from_dict (cls , config_dict : Dict [str , Any ]) -> "BaseConfig" :
1415 """
@@ -87,6 +88,7 @@ class LegendConfig(BaseConfig):
8788 1.2 ,
8889 0.5 ,
8990 ) # for fine control legend positioning in matplotlib
91+ ncol : int = 1 # number of columns in legend
9092
9193 @staticmethod
9294 def _matplotlibLegendLocationMapper (loc ):
@@ -288,7 +290,6 @@ class ScatterConfig(BasePlotConfig):
288290 )
289291
290292 def __post_init__ (self ):
291-
292293 super ().__post_init__ ()
293294 if not isinstance (self .marker , MarkerShapeGenerator ):
294295 self .marker = MarkerShapeGenerator (shapes = self .marker )
@@ -424,6 +425,10 @@ class PeakMapConfig(ScatterConfig):
424425 x_kind (str): Type of plot for the X-axis marginal. Defaults to "chromatogram".
425426 aggregation_method (Literal["mean", "sum", "max"]): Method for aggregating data. Defaults to "mean".
426427 annotation_data (pd.DataFrame | None): Data for annotations. Defaults to None.
428+ annotation_colormap (str): Colormap for annotations. Defaults to "Dark2".
429+ annotation_line_width (float): Width of the annotation lines. Defaults to 3.
430+ annotation_line_type (str): Type of the annotation lines (e.g., "solid", "dashed"). Defaults to "solid".
431+ annotation_legend_config (Dict | LegendConfig): Configuration for the annotation legend. Defaults to a LegendConfig instance with title "Features".
427432 xlabel (str): Label for the X-axis. Defaults to "Retention Time".
428433 ylabel (str): Label for the Y-axis. Defaults to "mass-to-charge".
429434 zlabel (str): Label for the Z-axis. Defaults to "Intensity".
@@ -448,6 +453,18 @@ def marginal_config_factory(kind):
448453
449454 aggregation_method : Literal ["mean" , "sum" , "max" ] = "mean"
450455 annotation_data : pd .DataFrame | None = None
456+ annotation_x_lb : str = "leftWidth"
457+ annotation_x_ub : str = "rightWidth"
458+ annotation_y_lb : str = "IM_leftWidth"
459+ annotation_y_ub : str = "IM_rightWidth"
460+ annotation_colors : str = "color"
461+ annotation_names : str = "name"
462+ annotation_colormap : str = "Dark2"
463+ annotation_line_width : float = 3
464+ annotation_line_type : str = "solid"
465+ annotation_legend_config : Dict | LegendConfig = field (
466+ default_factory = ScatterConfig .default_legend_factory
467+ )
451468
452469 ### override axes and title labels
453470 xlabel : str = "Retention Time"
@@ -498,6 +515,10 @@ def __post_init__(self):
498515 self .annotation_data = (
499516 None if self .annotation_data is None else self .annotation_data .copy ()
500517 )
518+ if not isinstance (self .annotation_legend_config , LegendConfig ):
519+ self .annotation_legend_config = LegendConfig .from_dict (
520+ self .annotation_legend_config
521+ )
501522
502523
503524def bokeh_line_dash_mapper (bokeh_dash , target_library = "plotly" ):
0 commit comments