pyfli.data_vnp.multi_plotter#

Class map ───────── PlotConfig @dataclass – visual + statistical defaults (shared) DataProcessor 2-D spatial cleaning (mask / threshold / NaN) SourceLoader Multi-source dict / npz / ndarray ingestion PlotKit Static axis-level draw primitives SubplotVisualizer Grid of spatial maps + 1-D distribution plots Plotter Multi-source comparison orchestrator

DLModelComparator W / KL / Energy metrics + plot

plot_2d_subplots() Backward-compatible module function

Functions

plot_2d_subplots(*data_arrays[, plot_types, ...])

Drop-in replacement – all original keyword arguments preserved.

Classes

DLModelComparator(*args[, values, ...])

Extend the general plotter with distribution-distance metrics for model evaluation.

DataProcessor()

Apply declarative preprocessing operations to two-dimensional arrays.

PlotConfig([figsize, cmap, bins, colors, ...])

Collect shared plotting and statistical defaults for comparison figures.

PlotKit()

Provide stateless axis-level plotting primitives.

Plotter(*args[, values, style_config, ...])

Run the plotter routine.

SourceLoader(*args[, values, source_names])

Normalize heterogeneous plot inputs into a consistent source dictionary.

SubplotVisualizer([config])

Build compact subplot grids for spatial maps and one-dimensional distributions.

class PlotConfig(figsize=(14, 8), cmap='viridis', bins=100, colors=<factory>, imshow_source='processed', shared_colorbar=False, annotate_stats=True, scatter_pair=None, qq_reference='norm', point_type='strip', show_mean=True, show_median=True, test_type='welch', correction=False)[source]#

Bases: object

Collect shared plotting and statistical defaults for comparison figures. Pass one configuration object to map, histogram, KDE, violin, box, CDF, QQ, scatter, and clustered comparison plots for consistent styling.

Parameters:
  • figsize (Tuple[int, int]) – Figure size passed to Matplotlib.

  • cmap (str) – Matplotlib colormap used for image and map rendering.

  • bins (int) – Histogram bin specification.

  • colors (List[str]) – Color sequence used for plotted groups.

  • imshow_source (str) – Data source used for image panels.

  • shared_colorbar (bool) – If True, draw one colorbar shared by comparable image panels.

  • annotate_stats (bool) – If True, annotate plots with summary statistics.

  • scatter_pair (Optional[Tuple[int, int]]) – Pair of variables to compare in a scatter plot.

  • qq_reference (str) – Reference distribution used for QQ plots.

  • point_type (str) – Marker style used for plotted points.

  • show_mean (bool) – If True, draw the group mean on distribution plots.

  • show_median (bool) – If True, draw the group median on distribution plots.

  • test_type (str) – Statistical test to apply when comparing groups.

  • correction (bool) – Multiple-comparison correction method.

figsize: tuple[int, int] = (14, 8)#
cmap: str = 'viridis'#
bins: int = 100#
colors: list[str]#
imshow_source: str = 'processed'#
shared_colorbar: bool = False#
annotate_stats: bool = True#
scatter_pair: tuple[int, int] | None = None#
qq_reference: str = 'norm'#
point_type: str = 'strip'#
show_mean: bool = True#
show_median: bool = True#
test_type: str = 'welch'#
correction: bool = False#
color(i)[source]#

Safely cycle through colors by index.

Parameters:

i (int)

Return type:

str

class DataProcessor[source]#

Bases: object

Apply declarative preprocessing operations to two-dimensional arrays. Operations include mask handling, thresholding, finite-value filtering, and simple summary statistics used by plotting classes.

MIN_SAMPLES: int = 5#
static process(data, operations=None)[source]#

Return (processed_map, valid_1d).

Parameters:
Return type:

tuple[ndarray, ndarray]

classmethod is_valid(valid, min_samples=None)[source]#

Return whether valid.

Parameters:
  • valid (np.ndarray) – Finite one-dimensional sample values used by a plot or statistic.

  • min_samples (Optional[int]) – Minimum number of finite samples required for a group.

Returns:

Boolean result computed by is valid.

Return type:

bool

static stats(valid)[source]#

Compute summary statistics for valid sample values.

Parameters:

valid (np.ndarray) – Finite one-dimensional sample values used by a plot or statistic.

Returns:

Object produced by stats.

Return type:

Dict[str, float]

class SourceLoader(*args, values=None, source_names=None)[source]#

Bases: object

Normalize heterogeneous plot inputs into a consistent source dictionary. It accepts direct arrays, dictionaries, or named value collections so downstream plotters can compare multiple data sources uniformly.

Parameters:
  • *args (Any) – Additional positional values accepted by the object.

  • values (np.ndarray | None) – Explicit values to load as plotting sources.

  • source_names (np.ndarray | None) – Names assigned to plotted or compared data sources.

load()[source]#

Return {label: [arr_per_source]}.

Return type:

dict[str, list[ndarray]]

class PlotKit[source]#

Bases: object

Provide stateless axis-level plotting primitives. The methods draw maps, histograms, KDEs, violin and box plots, CDFs, QQ plots, scatters, raincloud plots, and metric bars on caller-provided axes.

static map(ax, data_map, *, config=None, title='', vmin=None, vmax=None, fig=None, add_colorbar=True, **kw)[source]#

Draw a two-dimensional parameter map.

Parameters:
  • ax (Axes) – Matplotlib axes object on which the plot is drawn.

  • data_map (np.ndarray) – Parameter or mask map processed by the routine.

  • config (Any | None) – Plotting, fitting, or simulation configuration object.

  • title (str) – Title displayed on the generated plot.

  • vmin (np.ndarray | None) – Lower color-limit value.

  • vmax (np.ndarray | None) – Upper color-limit value.

  • fig (Any | None) – Matplotlib figure object to update or save.

  • add_colorbar (bool) – Whether to add a colorbar to the generated plot.

  • **kw (Any) – Additional keyword options forwarded to the underlying implementation.

Returns:

No object is returned; the function perform map.

Return type:

None

static histogram(ax, valid, *, config=None, title='', **kw)[source]#

Draw a histogram for valid sample values.

Parameters:
  • ax (Axes) – Matplotlib axes object on which the plot is drawn.

  • valid (np.ndarray) – Finite one-dimensional sample values used by a plot or statistic.

  • config (Any | None) – Plotting, fitting, or simulation configuration object.

  • title (str) – Title displayed on the generated plot.

  • **kw (Any) – Additional keyword options forwarded to the underlying implementation.

Returns:

No object is returned; the function perform histogram.

Return type:

None

static log_histogram(ax, valid, *, config=None, title='', **kw)[source]#

Draw a logarithmic histogram for valid sample values.

Parameters:
  • ax (Axes) – Matplotlib axes object on which the plot is drawn.

  • valid (np.ndarray) – Finite one-dimensional sample values used by a plot or statistic.

  • config (Any | None) – Plotting, fitting, or simulation configuration object.

  • title (str) – Title displayed on the generated plot.

  • **kw (Any) – Additional keyword options forwarded to the underlying implementation.

Returns:

No object is returned; the function perform log histogram.

Return type:

None

static kde(ax, valid, *, config=None, title='', color=None, label=None, fill=False, alpha=0.35, n_points=1000, **kw)[source]#

Draw a kernel-density estimate for valid sample values.

Parameters:
  • ax (Axes) – Matplotlib axes object on which the plot is drawn.

  • valid (np.ndarray) – Finite one-dimensional sample values used by a plot or statistic.

  • config (Any | None) – Plotting, fitting, or simulation configuration object.

  • title (str) – Title displayed on the generated plot.

  • color (str | None) – Matplotlib color used for drawing the plot element.

  • label (str | None) – Display label assigned to the data or plot element.

  • fill (bool) – Whether to fill the KDE area under the curve.

  • alpha (float) – Regularization strength, fraction value, or significance threshold used by the

  • routine.

  • n_points (int) – Number of points sampled for a curve or density.

  • **kw (Any) – Additional keyword options forwarded to the underlying implementation.

Returns:

No object is returned; the function perform kde.

Return type:

None

static violinplot(ax, valid, *, config=None, title='', **kw)[source]#

Draw a violin plot for valid sample values.

Parameters:
  • ax (Axes) – Matplotlib axes object on which the plot is drawn.

  • valid (np.ndarray) – Finite one-dimensional sample values used by a plot or statistic.

  • config (Any | None) – Plotting, fitting, or simulation configuration object.

  • title (str) – Title displayed on the generated plot.

  • **kw (Any) – Additional keyword options forwarded to the underlying implementation.

Returns:

No object is returned; the function perform violinplot.

Return type:

None

static boxplot(ax, valid, *, config=None, title='', **kw)[source]#

Draw a box plot for valid sample values.

Parameters:
  • ax (Axes) – Matplotlib axes object on which the plot is drawn.

  • valid (np.ndarray) – Finite one-dimensional sample values used by a plot or statistic.

  • config (Any | None) – Plotting, fitting, or simulation configuration object.

  • title (str) – Title displayed on the generated plot.

  • **kw (Any) – Additional keyword options forwarded to the underlying implementation.

Returns:

No object is returned; the function perform boxplot.

Return type:

None

static cdf(ax, valid, *, config=None, title='', color=None, label=None, **kw)[source]#

Draw an empirical cumulative distribution plot.

Parameters:
  • ax (Axes) – Matplotlib axes object on which the plot is drawn.

  • valid (np.ndarray) – Finite one-dimensional sample values used by a plot or statistic.

  • config (Any | None) – Plotting, fitting, or simulation configuration object.

  • title (str) – Title displayed on the generated plot.

  • color (str | None) – Matplotlib color used for drawing the plot element.

  • label (str | None) – Display label assigned to the data or plot element.

  • **kw (Any) – Additional keyword options forwarded to the underlying implementation.

Returns:

No object is returned; the function perform CDF.

Return type:

None

static qq(ax, valid, *, config=None, title='', **kw)[source]#

Draw a quantile-quantile diagnostic plot.

Parameters:
  • ax (Axes) – Matplotlib axes object on which the plot is drawn.

  • valid (np.ndarray) – Finite one-dimensional sample values used by a plot or statistic.

  • config (Any | None) – Plotting, fitting, or simulation configuration object.

  • title (str) – Title displayed on the generated plot.

  • **kw (Any) – Additional keyword options forwarded to the underlying implementation.

Returns:

No object is returned; the function perform QQ.

Return type:

None

static scatter(ax, x, y, *, config=None, title='', **kw)[source]#

Draw a scatter plot for paired arrays.

Parameters:
  • ax (Axes) – Matplotlib axes object on which the plot is drawn.

  • x (np.ndarray) – Input array, coordinate, or signal being transformed.

  • y (np.ndarray) – Observed signal, target data, or coordinate array.

  • config (Any | None) – Plotting, fitting, or simulation configuration object.

  • title (str) – Title displayed on the generated plot.

  • **kw (Any) – Additional keyword options forwarded to the underlying implementation.

Returns:

No object is returned; the function perform scatter.

Return type:

None

static raincloud(ax, valid, *, config=None, title='', color=None, position=0, width=0.4, **kw)[source]#

Half-violin + embedded box + jittered strip at a given x position.

Parameters:
Return type:

None

static metrics_bar(ax, metrics, *, config=None, title='Distribution Metrics', **kw)[source]#

Grouped bar chart of Wasserstein / Energy / KL per key × model.

Parameters:
Return type:

None

classmethod get_method(name)[source]#

Return method.

Parameters:

name (str) – Dataset, experiment, figure, or output name.

Returns:

Object produced by get method.

Return type:

Callable

class SubplotVisualizer(config=None, **kw)[source]#

Bases: object

Build compact subplot grids for spatial maps and one-dimensional distributions. It is useful when comparing several operations or plot types over a shared set of arrays.

Parameters:
  • config (Optional[PlotConfig]) – Plotting or processing configuration object.

  • **kw (Any) – Additional keyword arguments forwarded to the underlying implementation.

plot(*data_arrays, plot_types=('map', 'histogram', 'violinplot', 'boxplot'), titles=None, operations=None, fig=None, axes=None)[source]#

Run the plot routine.

Parameters:
  • *data_arrays (Any) – Arrays used to compute shared plot ranges.

  • plot_types (Sequence[str]) – Plot families requested by the caller.

  • titles (np.ndarray | None) – Subplot titles displayed by the visualizer.

  • operations (np.ndarray | None) – Processing operations applied before plotting or fitting.

  • fig (Any | None) – Matplotlib figure object to update or save.

  • axes (Any | None) – Matplotlib axes collection used for drawing subplots.

Returns:

Matplotlib figure generated by plot.

Return type:

Figure

class Plotter(*args, values=None, style_config=None, source_names=None, operations=None)[source]#

Bases: object

Run the plotter routine. class cleans data, applies processing operations, dispatches plot types, annotates significance, and exports underlying data.

Parameters:
  • *args (Any) – Additional positional values accepted by the object.

  • values (np.ndarray | None) – Explicit values to load as plotting sources.

  • style_config (np.ndarray | None) – Plot configuration object controlling colors, layout, and statistics.

  • source_names (np.ndarray | None) – Names assigned to plotted or compared data sources.

  • operations (np.ndarray | None) – List of plotting or analysis operations to execute.

stats_results: list[dict]#
current_fig: Figure | None#
make_plot(title='Data Analysis', graph_type='box', show_significance=True, point_type=None, show_mean=None, show_median=None, test_type=None, correction=None, **config_overrides)[source]#

Render a multi-source comparison plot.

Legacy parameters (point_type, show_mean, show_median, test_type, correction) are accepted directly as well as via config_overrides so existing call-sites continue to work unchanged.

Parameters:
Return type:

Any

make_cluster_plot(multi_cluster_mask, cluster_names=None, title='Cluster Analysis', graph_type='box', show_significance=True, point_type=None, show_mean=None, show_median=None, test_type=None, correction=None, **config_overrides)[source]#

Per-cluster breakdown of make_plot.

For every key in self.labels one subplot is drawn; within each subplot the x-axis represents cluster IDs and grouped boxes/violins/etc. represent data sources (color-coded by source).

Parameters:
  • multi_cluster_mask (2-D int array (H, W)) – 0 = background (ignored); 1, 2, 3 … = cluster IDs.

  • cluster_names (list[str], optional) – Display labels for each cluster. Auto-generated when None.

  • make_plot. (All remaining parameters are identical to)

  • values (Supported graph_type)

  • "violin"

  • "raincloud".

  • title (str)

  • graph_type (str)

  • show_significance (bool)

  • point_type (ndarray | None)

  • show_mean (ndarray | None)

  • show_median (ndarray | None)

  • test_type (ndarray | None)

  • correction (ndarray | None)

  • config_overrides (Any)

Return type:

Figure

export_data(save_pdf=False, save_png=False, save_csv=False, filename='results', dpi=150)[source]#

Export data.

Parameters:
  • save_pdf (bool) – If True, save the generated figures to a PDF file.

  • save_png (bool) – Whether to export the figure as PNG.

  • save_csv (bool) – Whether to export comparison data as CSV.

  • filename (str) – File name used for saving or loading results.

  • dpi (int) – Resolution used when saving a figure.

Returns:

No object is returned; the function export data.

Return type:

None

class DLModelComparator(*args, values=None, style_config=None, source_names=None, operations=None)[source]#

Bases: Plotter

Extend the general plotter with distribution-distance metrics for model evaluation. It computes Wasserstein, KL, and energy-style summaries and can annotate those metrics on comparison figures.

Parameters:
compute_distribution_metrics()[source]#

Compute distribution metrics.

Returns:

Object produced by compute distribution metrics.

Return type:

List[Dict]

annotate_distribution_metrics(ax)[source]#

Run the annotate distribution metrics routine.

Parameters:

ax (Axes) – Matplotlib axes object on which the plot is drawn.

Returns:

No object is returned; the function perform annotate distribution metrics.

Return type:

None

plot_metrics(title='Distribution Metrics')[source]#

Standalone bar chart of W / Energy / KL for all key × model pairs.

Parameters:

title (str)

Return type:

Figure | None

make_plot(title='DL Model Comparison', graph_type='box', show_significance=True, show_metrics=True, **config_overrides)[source]#

Override: adds optional distribution-metrics annotation block.

Parameters:
  • title (str)

  • graph_type (str)

  • show_significance (bool)

  • show_metrics (bool)

  • config_overrides (Any)

Return type:

ndarray

plot_2d_subplots(*data_arrays, plot_types=('map', 'histogram', 'violinplot', 'boxplot'), titles=None, operations=None, figsize=(18, 8), cmap='viridis', bins=100, imshow_source='processed', shared_colorbar=False, annotate_stats=True, scatter_pair=None, qq_reference='norm')[source]#

Drop-in replacement – all original keyword arguments preserved.

Parameters:
Return type:

Figure