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
|
Drop-in replacement – all original keyword arguments preserved. |
Classes
|
Extend the general plotter with distribution-distance metrics for model evaluation. |
Apply declarative preprocessing operations to two-dimensional arrays. |
|
|
Collect shared plotting and statistical defaults for comparison figures. |
|
Provide stateless axis-level plotting primitives. |
|
Run the plotter routine. |
|
Normalize heterogeneous plot inputs into a consistent source dictionary. |
|
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:
objectCollect 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) – IfTrue, draw one colorbar shared by comparable image panels.annotate_stats (
bool) – IfTrue, 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) – IfTrue, draw the group mean on distribution plots.show_median (
bool) – IfTrue, draw the group median on distribution plots.test_type (
str) – Statistical test to apply when comparing groups.correction (
bool) – Multiple-comparison correction method.
- class DataProcessor[source]#
Bases:
objectApply declarative preprocessing operations to two-dimensional arrays. Operations include mask handling, thresholding, finite-value filtering, and simple summary statistics used by plotting classes.
- 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:
- class SourceLoader(*args, values=None, source_names=None)[source]#
Bases:
objectNormalize 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.
- class PlotKit[source]#
Bases:
objectProvide 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:
- 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:
- 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:
- 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 theroutine.
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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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.
- class SubplotVisualizer(config=None, **kw)[source]#
Bases:
objectBuild 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:
objectRun 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.
- 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.
- 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.labelsone 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:
- class DLModelComparator(*args, values=None, style_config=None, source_names=None, operations=None)[source]#
Bases:
PlotterExtend 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:
- plot_metrics(title='Distribution Metrics')[source]#
Standalone bar chart of W / Energy / KL for all key × model pairs.
- 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.