diff --git a/.url_check_allowlist.txt b/.url_check_allowlist.txt
index 7105704ee3..fbee1e6e3d 100644
--- a/.url_check_allowlist.txt
+++ b/.url_check_allowlist.txt
@@ -8,21 +8,16 @@
# Academic citations (paywall / DOI / journal)
https://academic.oup.com/mnras/article-abstract/478/4/4738/5001434?redirectedFrom=fulltext # CITATIONS.md:11
-https://academic.oup.com/mnras/article-abstract/489/2/2049/5550746 # docs/index.md:35
-https://academic.oup.com/mnras/article/442/3/2017/1048278 # docs/index.md:36
https://academic.oup.com/mnras/article/452/3/2940/1749640 # CITATIONS.md:11
-https://academic.oup.com/mnras/article/468/3/2590/3055701 # docs/index.md:37
https://academic.oup.com/mnras/article/488/1/1387/5526256 # CITATIONS.md:22
# Code of Conduct boilerplate
-http://geekfeminism.wikia.com/wiki/Conference_anti-harassment/Policy # CODE_OF_CONDUCT.md:305
# External dead / paywalled / departmental pages
http://www.ita.uni-heidelberg.de/~massimo/sub/Lectures/gl_all.pdf # docs/howtolens/howtolens.md:36
https://bitbucket.org/bdiemer/colossus/src/main/ # files/citations.md:12
# GitHub refs (workspaces / removed tutorials)
-https://github.com/PyAutoLabs/autolens_workspace/blob/main/notebooks/imaging/advanced/chaining/start_here.ipynb # docs/general/model_cookbook.md:384
https://github.com/PyAutoLabs/autolens_workspace/blob/main/scripts/imaging/preprocess/gui/positions.py # docs/general/demagnified_solutions.md:73
# Internal PyAuto docs — pages renamed, need editorial fix
diff --git a/AGENTS.md b/AGENTS.md
index 1290612c52..b38798c922 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -75,7 +75,7 @@ parity scripts in `autolens_workspace_test` (`jax.jit` round-trip +
`fitness._vmap` batch eval) — never by `test_autolens/`.
Full detail lives in PyAutoArray:
-**[`PyAutoArray/docs/agents/jax_and_decorators.md`](../PyAutoArray/docs/agents/jax_and_decorators.md)**.
+**[`PyAutoArray/docs/agents/jax_and_decorators.md`](https://github.com/PyAutoLabs/PyAutoArray/blob/main/docs/agents/jax_and_decorators.md)**.
## Public API
@@ -108,7 +108,7 @@ Profiles re-export from autogalaxy (`al.mp.*`, `al.lp.*`) alongside `al.Galaxy`,
## Deep dives
-- [`PyAutoArray/docs/agents/jax_and_decorators.md`](../PyAutoArray/docs/agents/jax_and_decorators.md)
+- [`PyAutoArray/docs/agents/jax_and_decorators.md`](https://github.com/PyAutoLabs/PyAutoArray/blob/main/docs/agents/jax_and_decorators.md)
— decorator system, `xp` backend pattern, and the `jax.jit` boundary.
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
index 3b5671a259..bcf7cca605 100644
--- a/CODE_OF_CONDUCT.md
+++ b/CODE_OF_CONDUCT.md
@@ -2,4 +2,4 @@
PyAutoLabs uses one Code of Conduct across all of its repositories.
-Read the [canonical PyAutoLabs Code of Conduct](https://github.com/PyAutoLabs/PyAutoScientist/blob/main/CODE_OF_CONDUCT.md).
+Read the [canonical PyAutoLabs Code of Conduct](https://github.com/PyAutoLabs/.github/blob/main/CODE_OF_CONDUCT.md).
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index b7df3e4de4..d289b9c2bb 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -2,7 +2,7 @@
PyAutoLabs maintains its shared contribution guidance in one place.
-Read the [canonical PyAutoLabs contribution guide](https://github.com/PyAutoLabs/PyAutoScientist/blob/main/CONTRIBUTING.md).
+Read the [canonical PyAutoLabs contribution guide](https://github.com/PyAutoLabs/.github/blob/main/CONTRIBUTING.md).
Repository-specific setup, test commands, and editing rules are documented in
that repository's `README.md` and `AGENTS.md`, where present.
diff --git a/README.md b/README.md
index 13f58789b7..73bd4aefd4 100644
--- a/README.md
+++ b/README.md
@@ -1,27 +1,8 @@
# PyAutoLens-JAX: Open-Source Strong Lensing
-[](https://colab.research.google.com/github/PyAutoLabs/autolens_workspace/blob/2026.11.9.1/start_here.ipynb)
-[](https://pyautolens.readthedocs.io/en/latest/?badge=latest)
-[](https://github.com/PyAutoLabs/PyAutoLens/actions)
-[](https://github.com/PyAutoLabs/PyAutoHands/actions)
-[](https://github.com/psf/black)
-[](https://doi.org/10.21105/joss.02825)
-[](https://doi.org/10.5281/zenodo.4548697)
-[](https://arxiv.org/abs/1708.07377)
-[](https://www.repostatus.org/#active)
-[](https://pypi.org/project/autolens/)
-[](https://pypi.org/project/autolens/)
-
-[Installation Guide](https://pyautolens.readthedocs.io/en/latest/installation/overview.html) |
-[readthedocs](https://pyautolens.readthedocs.io/en/latest/index.html) |
-[Introduction on Colab](https://colab.research.google.com/github/PyAutoLabs/autolens_workspace/blob/2026.11.9.1/start_here.ipynb) |
-[HowToLens](https://pyautolens.readthedocs.io/en/latest/howtolens/howtolens.html)
-
-When two or more galaxies are aligned perfectly down our line-of-sight, the background galaxy appears multiple times.
-
-This is called strong gravitational lensing and **PyAutoLens** makes it **simple** to model strong gravitational lenses, using JAX to **accelerate lens modeling on GPUs**.
+**PyAutoLens** lets you simulate and model strong gravitational lenses, using JAX to accelerate lens modeling on GPUs. Explore examples, analyse your own observations and learn how lensing reveals the galaxies and matter along our line of sight.
## Getting Started
@@ -31,49 +12,39 @@ This is called strong gravitational lensing and **PyAutoLens** makes it **simple
- **[Try it in your browser](https://colab.research.google.com/github/PyAutoLabs/autolens_workspace/blob/2026.11.9.1/start_here.ipynb)** — run the introductory notebook without installing anything.
- **[Install PyAutoLens](https://pyautolens.readthedocs.io/en/latest/installation/overview.html)** — get set up on your computer.
-Explore more examples in the [workspace](https://github.com/PyAutoLabs/autolens_workspace), or learn lensing from the ground up with [HowToLens](https://github.com/PyAutoLabs/HowToLens).
+Visit the [workspace](https://github.com/PyAutoLabs/autolens_workspace#find-your-examples) to find examples for your data and science goals.
### Explore with AI
-The [**PyAutoLens AI Assistant**](https://github.com/PyAutoLabs/autolens_assistant) lets you explore
-gravitational lensing through conversation. Ask a question, explore an idea, or describe the analysis
-you want to run. Both routes use the same software. To get started, paste this prompt into Claude Code, Codex
-or another AI coding agent:
-
-Starting prompt for Claude Code, Codex or other AI coding agent
+The [**PyAutoLens AI Assistant**](https://github.com/PyAutoLabs/autolens_assistant) helps you learn lensing, run examples and analyse your own data through conversation. To get started, paste this prompt into your AI coding agent:
```text
-I want to do strong lensing science with PyAutoLens (https://github.com/PyAutoLabs/PyAutoLens) and the
-autolens_assistant (https://github.com/PyAutoLabs/autolens_assistant). First clone that repository,
-cd into it and follow its AGENTS.md.
+I want to do strong lensing science with PyAutoLens
+(https://github.com/PyAutoLabs/PyAutoLens) and the
+autolens_assistant (https://github.com/PyAutoLabs/autolens_assistant).
+First clone the assistant repository, cd into it and follow its AGENTS.md.
Begin the "start here" guide for a new user.
```
-The assistant guides you through [Start Here](https://pyautolens.readthedocs.io/en/latest/overview/overview_1_start_here.html)
-as a conversation, then helps you analyse your own lenses. See [AI Options](https://github.com/PyAutoLabs/PyAutoScientist/blob/main/AI_OPTIONS.md)
-for recommended tools, costs and free alternatives.
+See [AI Options](https://github.com/PyAutoLabs/PyAutoScientist/blob/main/AI_OPTIONS.md) for tools and setup guidance.
-## Community & Contributing
+## Learn Lensing
-**PyAutoLens** is built in the open by its users: everyone is welcome to ask questions,
-share what they have made with it, and contribute.
+[**HowToLens**](https://github.com/PyAutoLabs/HowToLens) teaches gravitational lensing and Bayesian inference through worked notebooks, starting from undergraduate level.
-Questions, ideas and bug reports: the [PyAutoLabs Discussions](https://github.com/orgs/PyAutoLabs/discussions).
-Chat with us on [Slack](https://join.slack.com/t/pyautolens/shared_invite/zt-2cufp4eyf-fXfgMxRGuvg~bMrI3uOAxg).
+The [PyAutoLens documentation](https://pyautolens.readthedocs.io/en/latest/index.html) covers the software’s features and how to use them in your own analysis.
-Community-built tools and tutorials, and how to contribute: the [**PyAutoLens** community page](https://pyautolens.readthedocs.io/en/latest/general/community.html).
+## Community and Contributing
-## HowToLens
+Ask questions, suggest improvements and share your work in [PyAutoLabs Discussions](https://github.com/orgs/PyAutoLabs/discussions), or chat with us on [Slack](https://join.slack.com/t/pyautolens/shared_invite/zt-2cufp4eyf-fXfgMxRGuvg~bMrI3uOAxg).
-For users less familiar with gravitational lensing, Bayesian inference and scientific analysis
-you may wish to read through the **HowToLens** lectures. These teach you the basic principles of gravitational lensing
-and Bayesian inference, with the content pitched at undergraduate level and above.
-
-A complete overview of the lectures [is provided on the HowToLens readthedocs page](https://pyautolens.readthedocs.io/en/latest/howtolens/howtolens.html), and the notebooks themselves live in the [PyAutoLabs/HowToLens](https://github.com/PyAutoLabs/HowToLens) repository.
+To contribute or explore community projects, visit the [PyAutoLens community page](https://pyautolens.readthedocs.io/en/latest/general/community.html).
## Citations
-Information on how to cite **PyAutoLens** in publications can be found [on the citations page](https://github.com/PyAutoLabs/PyAutoLens/blob/main/CITATIONS.md).
+If you use PyAutoLens in your research, see the [citation guide](https://github.com/PyAutoLabs/PyAutoLens/blob/main/CITATIONS.md).
+
+## License
-i found you, i found you, i found you beautiful, exploding, i found you
+See the [license](https://github.com/PyAutoLabs/PyAutoLens/blob/main/LICENSE).
diff --git a/libraries.txt b/libraries.txt
deleted file mode 100644
index 3bb5d6107e..0000000000
--- a/libraries.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-Profiling Code:
-https://docs.python.org/2/library/profile.html
-
-Compiling to machine code:
-https://numba.pydata.org/
-
-Multiprocessing:
-https://github.com/soravux/scoop
diff --git a/patches/autoarray/0001-PR-A1-Add-autoarray-plot-plots-direct-matplotlib-mod.patch b/patches/autoarray/0001-PR-A1-Add-autoarray-plot-plots-direct-matplotlib-mod.patch
deleted file mode 100644
index 1094db1f78..0000000000
--- a/patches/autoarray/0001-PR-A1-Add-autoarray-plot-plots-direct-matplotlib-mod.patch
+++ /dev/null
@@ -1,864 +0,0 @@
-From bf29f6dbd7ca37fc15c8aa9a8956b87e10627e1c Mon Sep 17 00:00:00 2001
-From: Claude
-Date: Mon, 16 Mar 2026 14:08:58 +0000
-Subject: [PATCH 1/3] PR A1: Add autoarray/plot/plots/ direct-matplotlib module
-
-New standalone functions that replace MatPlot2D/MatPlot1D/MatWrap:
-
- plot_array() - imshow-based 2D array plot
- plot_grid() - scatter/errorbar grid plot
- plot_yx() - 1D y-vs-x line/errorbar plot
- plot_inversion_reconstruction() - rectangular + Delaunay mapper plots
- save_figure() - replaces Output class
- conf_figsize() - reads figsize from general.yaml
- apply_extent() - 3-tick linear axis limits helper
-
-ax=None creates its own figure; ax provided draws onto caller's axes.
-Overlay data (lines, positions, mask) passed as plain list/array args.
-3 linear ticks via np.linspace; log colorbars via LogNorm to imshow.
-Purely additive - all existing tests continue to pass.
-
-https://claude.ai/code/session_01CzJBy8KvFXiNchoNdk5i9k
----
- autoarray/plot/__init__.py | 10 ++
- autoarray/plot/plots/__init__.py | 15 +++
- autoarray/plot/plots/array.py | 192 ++++++++++++++++++++++++++++++
- autoarray/plot/plots/grid.py | 156 ++++++++++++++++++++++++
- autoarray/plot/plots/inversion.py | 180 ++++++++++++++++++++++++++++
- autoarray/plot/plots/utils.py | 96 +++++++++++++++
- autoarray/plot/plots/yx.py | 131 ++++++++++++++++++++
- 7 files changed, 780 insertions(+)
- create mode 100644 autoarray/plot/plots/__init__.py
- create mode 100644 autoarray/plot/plots/array.py
- create mode 100644 autoarray/plot/plots/grid.py
- create mode 100644 autoarray/plot/plots/inversion.py
- create mode 100644 autoarray/plot/plots/utils.py
- create mode 100644 autoarray/plot/plots/yx.py
-
-diff --git a/autoarray/plot/__init__.py b/autoarray/plot/__init__.py
-index 1ec4ff8a..6b967dab 100644
---- a/autoarray/plot/__init__.py
-+++ b/autoarray/plot/__init__.py
-@@ -59,3 +59,13 @@ from autoarray.fit.plot.fit_interferometer_plotters import FitInterferometerPlot
-
- from autoarray.plot.multi_plotters import MultiFigurePlotter
- from autoarray.plot.multi_plotters import MultiYX1DPlotter
-+
-+from autoarray.plot.plots import (
-+ plot_array,
-+ plot_grid,
-+ plot_yx,
-+ plot_inversion_reconstruction,
-+ apply_extent,
-+ conf_figsize,
-+ save_figure,
-+)
-diff --git a/autoarray/plot/plots/__init__.py b/autoarray/plot/plots/__init__.py
-new file mode 100644
-index 00000000..e8920734
---- /dev/null
-+++ b/autoarray/plot/plots/__init__.py
-@@ -0,0 +1,15 @@
-+from autoarray.plot.plots.array import plot_array
-+from autoarray.plot.plots.grid import plot_grid
-+from autoarray.plot.plots.yx import plot_yx
-+from autoarray.plot.plots.inversion import plot_inversion_reconstruction
-+from autoarray.plot.plots.utils import apply_extent, conf_figsize, save_figure
-+
-+__all__ = [
-+ "plot_array",
-+ "plot_grid",
-+ "plot_yx",
-+ "plot_inversion_reconstruction",
-+ "apply_extent",
-+ "conf_figsize",
-+ "save_figure",
-+]
-diff --git a/autoarray/plot/plots/array.py b/autoarray/plot/plots/array.py
-new file mode 100644
-index 00000000..20f5f267
---- /dev/null
-+++ b/autoarray/plot/plots/array.py
-@@ -0,0 +1,192 @@
-+"""
-+Standalone function for plotting a 2D array (image) directly with matplotlib.
-+
-+This replaces the ``MatPlot2D.plot_array`` / ``MatWrap`` system with a plain
-+function whose defaults are ordinary Python parameter defaults rather than
-+values loaded from YAML config files.
-+"""
-+import os
-+from typing import List, Optional, Tuple
-+
-+import matplotlib.pyplot as plt
-+import numpy as np
-+from matplotlib.colors import LogNorm, Normalize
-+
-+from autoarray.plot.plots.utils import apply_extent, conf_figsize, save_figure
-+
-+
-+def plot_array(
-+ array: np.ndarray,
-+ ax: Optional[plt.Axes] = None,
-+ # --- spatial metadata -------------------------------------------------------
-+ extent: Optional[Tuple[float, float, float, float]] = None,
-+ # --- overlays ---------------------------------------------------------------
-+ mask: Optional[np.ndarray] = None,
-+ grid: Optional[np.ndarray] = None,
-+ positions: Optional[List[np.ndarray]] = None,
-+ lines: Optional[List[np.ndarray]] = None,
-+ vector_yx: Optional[np.ndarray] = None,
-+ array_overlay: Optional[np.ndarray] = None,
-+ # --- cosmetics --------------------------------------------------------------
-+ title: str = "",
-+ xlabel: str = 'x (")',
-+ ylabel: str = 'y (")',
-+ colormap: str = "jet",
-+ vmin: Optional[float] = None,
-+ vmax: Optional[float] = None,
-+ use_log10: bool = False,
-+ aspect: str = "auto",
-+ origin: str = "upper",
-+ # --- figure control (used only when ax is None) -----------------------------
-+ figsize: Optional[Tuple[int, int]] = None,
-+ output_path: Optional[str] = None,
-+ output_filename: str = "array",
-+ output_format: str = "png",
-+) -> None:
-+ """
-+ Plot a 2D array (image) using ``plt.imshow``.
-+
-+ This is the direct-matplotlib replacement for ``MatPlot2D.plot_array``.
-+
-+ Parameters
-+ ----------
-+ array
-+ 2D numpy array of pixel values.
-+ ax
-+ Existing matplotlib ``Axes`` to draw onto. If ``None`` a new figure
-+ is created and saved / shown according to *output_path*.
-+ extent
-+ ``[xmin, xmax, ymin, ymax]`` spatial extent in data coordinates.
-+ When ``None`` the array pixel indices are used by matplotlib.
-+ mask
-+ Array of shape ``(N, 2)`` with ``(y, x)`` coordinates of masked
-+ pixels to overlay as black dots.
-+ grid
-+ Array of shape ``(N, 2)`` with ``(y, x)`` coordinates to scatter.
-+ positions
-+ List of ``(N, 2)`` arrays; each is scattered as a distinct group
-+ of lensed image positions.
-+ lines
-+ List of ``(N, 2)`` arrays with ``(y, x)`` columns to plot as lines
-+ (e.g. critical curves, caustics).
-+ vector_yx
-+ Array of shape ``(N, 4)`` — ``(y, x, vy, vx)`` — plotted as quiver
-+ arrows.
-+ array_overlay
-+ A second 2D array rendered on top of *array* with partial alpha.
-+ title
-+ Figure title string.
-+ xlabel, ylabel
-+ Axis label strings.
-+ colormap
-+ Matplotlib colormap name.
-+ vmin, vmax
-+ Explicit color scale limits. When ``None`` the data range is used.
-+ use_log10
-+ When ``True`` a ``LogNorm`` is applied.
-+ aspect
-+ Passed directly to ``imshow``.
-+ origin
-+ Passed directly to ``imshow`` (``"upper"`` or ``"lower"``).
-+ figsize
-+ Figure size in inches ``(width, height)``. Falls back to the value
-+ in ``visualize/general.yaml`` when ``None``.
-+ output_path
-+ Directory to save the figure. When empty / ``None`` ``plt.show()``
-+ is called instead.
-+ output_filename
-+ Base file name (without extension).
-+ output_format
-+ File format, e.g. ``"png"``.
-+ """
-+ if array is None or np.all(array == 0):
-+ return
-+
-+ owns_figure = ax is None
-+ if owns_figure:
-+ figsize = figsize or conf_figsize("figures")
-+ fig, ax = plt.subplots(1, 1, figsize=figsize)
-+ else:
-+ fig = ax.get_figure()
-+
-+ # --- colour normalisation --------------------------------------------------
-+ if use_log10:
-+ from autonerves import conf as _conf
-+
-+ try:
-+ log10_min = _conf.instance["visualize"]["general"]["general"][
-+ "log10_min_value"
-+ ]
-+ except Exception:
-+ log10_min = 1.0e-4
-+
-+ clipped = np.clip(array, log10_min, None)
-+ norm = LogNorm(vmin=vmin or log10_min, vmax=vmax or clipped.max())
-+ elif vmin is not None or vmax is not None:
-+ norm = Normalize(vmin=vmin, vmax=vmax)
-+ else:
-+ norm = None
-+
-+ im = ax.imshow(
-+ array,
-+ cmap=colormap,
-+ norm=norm,
-+ extent=extent,
-+ aspect=aspect,
-+ origin=origin,
-+ )
-+
-+ plt.colorbar(im, ax=ax)
-+
-+ # --- overlays --------------------------------------------------------------
-+ if array_overlay is not None:
-+ ax.imshow(
-+ array_overlay,
-+ cmap="Greys",
-+ alpha=0.5,
-+ extent=extent,
-+ aspect=aspect,
-+ origin=origin,
-+ )
-+
-+ if mask is not None:
-+ ax.scatter(mask[:, 1], mask[:, 0], s=1, c="k")
-+
-+ if grid is not None:
-+ ax.scatter(grid[:, 1], grid[:, 0], s=1, c="k")
-+
-+ if positions is not None:
-+ colors = ["r", "g", "b", "m", "c", "y"]
-+ for i, pos in enumerate(positions):
-+ ax.scatter(pos[:, 1], pos[:, 0], s=20, c=colors[i % len(colors)], zorder=5)
-+
-+ if lines is not None:
-+ for line in lines:
-+ if line is not None and len(line) > 0:
-+ ax.plot(line[:, 1], line[:, 0], linewidth=2)
-+
-+ if vector_yx is not None:
-+ ax.quiver(
-+ vector_yx[:, 1],
-+ vector_yx[:, 0],
-+ vector_yx[:, 3],
-+ vector_yx[:, 2],
-+ )
-+
-+ # --- labels / ticks --------------------------------------------------------
-+ ax.set_title(title, fontsize=16)
-+ ax.set_xlabel(xlabel, fontsize=14)
-+ ax.set_ylabel(ylabel, fontsize=14)
-+ ax.tick_params(labelsize=12)
-+
-+ if extent is not None:
-+ apply_extent(ax, extent)
-+
-+ # --- output ----------------------------------------------------------------
-+ if owns_figure:
-+ save_figure(
-+ fig,
-+ path=output_path or "",
-+ filename=output_filename,
-+ format=output_format,
-+ )
-diff --git a/autoarray/plot/plots/grid.py b/autoarray/plot/plots/grid.py
-new file mode 100644
-index 00000000..b310a5f7
---- /dev/null
-+++ b/autoarray/plot/plots/grid.py
-@@ -0,0 +1,156 @@
-+"""
-+Standalone function for plotting a 2D grid of (y, x) coordinates.
-+
-+This replaces the ``MatPlot2D.plot_grid`` / ``MatWrap`` system.
-+"""
-+from typing import Iterable, List, Optional, Tuple
-+
-+import matplotlib.pyplot as plt
-+import numpy as np
-+
-+from autoarray.plot.plots.utils import apply_extent, conf_figsize, save_figure
-+
-+
-+def plot_grid(
-+ grid: np.ndarray,
-+ ax: Optional[plt.Axes] = None,
-+ # --- errors -----------------------------------------------------------------
-+ y_errors: Optional[np.ndarray] = None,
-+ x_errors: Optional[np.ndarray] = None,
-+ # --- overlays ---------------------------------------------------------------
-+ lines: Optional[Iterable[np.ndarray]] = None,
-+ color_array: Optional[np.ndarray] = None,
-+ # --- cosmetics --------------------------------------------------------------
-+ title: str = "",
-+ xlabel: str = 'x (")',
-+ ylabel: str = 'y (")',
-+ colormap: str = "jet",
-+ buffer: float = 0.1,
-+ extent: Optional[Tuple[float, float, float, float]] = None,
-+ force_symmetric_extent: bool = True,
-+ # --- figure control (used only when ax is None) -----------------------------
-+ figsize: Optional[Tuple[int, int]] = None,
-+ output_path: Optional[str] = None,
-+ output_filename: str = "grid",
-+ output_format: str = "png",
-+) -> None:
-+ """
-+ Plot a 2D grid of ``(y, x)`` coordinates as a scatter plot.
-+
-+ This is the direct-matplotlib replacement for ``MatPlot2D.plot_grid``.
-+
-+ Parameters
-+ ----------
-+ grid
-+ Array of shape ``(N, 2)``; column 0 is *y*, column 1 is *x*.
-+ ax
-+ Existing ``Axes`` to draw onto. ``None`` creates a new figure.
-+ y_errors, x_errors
-+ Per-point error values; when provided ``plt.errorbar`` is used.
-+ lines
-+ Iterable of ``(N, 2)`` arrays (y, x columns) drawn as lines.
-+ color_array
-+ 1D array of scalar values for colouring each point; triggers a
-+ colorbar.
-+ title
-+ Figure title.
-+ xlabel, ylabel
-+ Axis labels.
-+ colormap
-+ Matplotlib colormap name.
-+ buffer
-+ Fractional padding for the auto-computed extent. The grid's
-+ ``extent_with_buffer_from`` method is called when *extent* is
-+ ``None`` and the grid object exposes that method.
-+ extent
-+ Manual axis limits ``[xmin, xmax, ymin, ymax]``. Auto-computed
-+ when ``None``.
-+ force_symmetric_extent
-+ When ``True`` (and *extent* is auto-computed) the limits are made
-+ symmetric about the origin so the plot is centred.
-+ figsize
-+ Figure size in inches ``(width, height)``.
-+ output_path
-+ Directory for saving. Empty string / ``None`` triggers
-+ ``plt.show()``.
-+ output_filename
-+ Base file name without extension.
-+ output_format
-+ File format, e.g. ``"png"``.
-+ """
-+ owns_figure = ax is None
-+ if owns_figure:
-+ figsize = figsize or conf_figsize("figures")
-+ fig, ax = plt.subplots(1, 1, figsize=figsize)
-+ else:
-+ fig = ax.get_figure()
-+
-+ # --- scatter / errorbar ----------------------------------------------------
-+ if color_array is not None:
-+ cmap = plt.get_cmap(colormap)
-+ colors = cmap((color_array - color_array.min()) / (color_array.ptp() or 1))
-+
-+ if y_errors is None and x_errors is None:
-+ sc = ax.scatter(grid[:, 1], grid[:, 0], s=1, c=color_array, cmap=colormap)
-+ else:
-+ sc = ax.scatter(grid[:, 1], grid[:, 0], s=1, c=color_array, cmap=colormap)
-+ ax.errorbar(
-+ grid[:, 1],
-+ grid[:, 0],
-+ yerr=y_errors,
-+ xerr=x_errors,
-+ fmt="none",
-+ ecolor=colors,
-+ )
-+
-+ plt.colorbar(sc, ax=ax)
-+ else:
-+ if y_errors is None and x_errors is None:
-+ ax.scatter(grid[:, 1], grid[:, 0], s=1, c="k")
-+ else:
-+ ax.errorbar(
-+ grid[:, 1],
-+ grid[:, 0],
-+ yerr=y_errors,
-+ xerr=x_errors,
-+ fmt="o",
-+ markersize=2,
-+ color="k",
-+ )
-+
-+ # --- line overlays ---------------------------------------------------------
-+ if lines is not None:
-+ for line in lines:
-+ if line is not None and len(line) > 0:
-+ ax.plot(line[:, 1], line[:, 0], linewidth=2)
-+
-+ # --- labels ----------------------------------------------------------------
-+ ax.set_title(title, fontsize=16)
-+ ax.set_xlabel(xlabel, fontsize=14)
-+ ax.set_ylabel(ylabel, fontsize=14)
-+ ax.tick_params(labelsize=12)
-+
-+ # --- extent ----------------------------------------------------------------
-+ if extent is None:
-+ try:
-+ extent = grid.extent_with_buffer_from(buffer=buffer)
-+ except AttributeError:
-+ y_vals = grid[:, 0]
-+ x_vals = grid[:, 1]
-+ extent = [x_vals.min(), x_vals.max(), y_vals.min(), y_vals.max()]
-+
-+ if force_symmetric_extent and extent is not None:
-+ x_abs = max(abs(extent[0]), abs(extent[1]))
-+ y_abs = max(abs(extent[2]), abs(extent[3]))
-+ extent = [-x_abs, x_abs, -y_abs, y_abs]
-+
-+ apply_extent(ax, extent)
-+
-+ # --- output ----------------------------------------------------------------
-+ if owns_figure:
-+ save_figure(
-+ fig,
-+ path=output_path or "",
-+ filename=output_filename,
-+ format=output_format,
-+ )
-diff --git a/autoarray/plot/plots/inversion.py b/autoarray/plot/plots/inversion.py
-new file mode 100644
-index 00000000..a58d9e89
---- /dev/null
-+++ b/autoarray/plot/plots/inversion.py
-@@ -0,0 +1,180 @@
-+"""
-+Standalone functions for plotting inversion / pixelization reconstructions.
-+
-+Replaces the inversion-specific paths in ``MatPlot2D.plot_mapper``.
-+"""
-+from typing import List, Optional, Tuple
-+
-+import matplotlib.pyplot as plt
-+import numpy as np
-+from matplotlib.colors import LogNorm, Normalize
-+
-+from autoarray.plot.plots.utils import apply_extent, conf_figsize, save_figure
-+
-+
-+def plot_inversion_reconstruction(
-+ pixel_values: np.ndarray,
-+ mapper,
-+ ax: Optional[plt.Axes] = None,
-+ # --- cosmetics --------------------------------------------------------------
-+ title: str = "Reconstruction",
-+ xlabel: str = 'x (")',
-+ ylabel: str = 'y (")',
-+ colormap: str = "jet",
-+ vmin: Optional[float] = None,
-+ vmax: Optional[float] = None,
-+ use_log10: bool = False,
-+ zoom_to_brightest: bool = True,
-+ # --- overlays ---------------------------------------------------------------
-+ lines: Optional[List[np.ndarray]] = None,
-+ grid: Optional[np.ndarray] = None,
-+ # --- figure control (used only when ax is None) -----------------------------
-+ figsize: Optional[Tuple[int, int]] = None,
-+ output_path: Optional[str] = None,
-+ output_filename: str = "reconstruction",
-+ output_format: str = "png",
-+) -> None:
-+ """
-+ Plot an inversion reconstruction using the appropriate mapper type.
-+
-+ Chooses between rectangular (``imshow``/``pcolormesh``) and Delaunay
-+ (``tripcolor``) rendering based on the mapper's interpolator type.
-+
-+ Parameters
-+ ----------
-+ pixel_values
-+ 1D array of reconstructed flux values, one per source pixel.
-+ mapper
-+ Autoarray mapper object exposing ``interpolator``, ``mesh_geometry``,
-+ ``source_plane_mesh_grid``, etc.
-+ ax
-+ Existing ``Axes``. ``None`` creates a new figure.
-+ title, xlabel, ylabel
-+ Text labels.
-+ colormap
-+ Matplotlib colormap name.
-+ vmin, vmax
-+ Explicit colour scale limits.
-+ use_log10
-+ Apply ``LogNorm``.
-+ zoom_to_brightest
-+ Pass through to ``mapper.extent_from``.
-+ lines
-+ Line overlays (e.g. critical curves).
-+ grid
-+ Scatter overlay (e.g. data-plane grid).
-+ figsize, output_path, output_filename, output_format
-+ Figure output controls.
-+ """
-+ from autoarray.inversion.mesh.interpolator.rectangular import (
-+ InterpolatorRectangular,
-+ )
-+ from autoarray.inversion.mesh.interpolator.rectangular_uniform import (
-+ InterpolatorRectangularUniform,
-+ )
-+ from autoarray.inversion.mesh.interpolator.delaunay import InterpolatorDelaunay
-+ from autoarray.inversion.mesh.interpolator.knn import InterpolatorKNearestNeighbor
-+
-+ owns_figure = ax is None
-+ if owns_figure:
-+ figsize = figsize or conf_figsize("figures")
-+ fig, ax = plt.subplots(1, 1, figsize=figsize)
-+ else:
-+ fig = ax.get_figure()
-+
-+ # --- colour normalisation --------------------------------------------------
-+ if use_log10:
-+ norm = LogNorm(vmin=vmin or 1e-4, vmax=vmax)
-+ elif vmin is not None or vmax is not None:
-+ norm = Normalize(vmin=vmin, vmax=vmax)
-+ else:
-+ norm = None
-+
-+ extent = mapper.extent_from(values=pixel_values, zoom_to_brightest=zoom_to_brightest)
-+
-+ if isinstance(mapper.interpolator, (InterpolatorRectangular, InterpolatorRectangularUniform)):
-+ _plot_rectangular(ax, pixel_values, mapper, norm, colormap, extent)
-+ elif isinstance(mapper.interpolator, (InterpolatorDelaunay, InterpolatorKNearestNeighbor)):
-+ _plot_delaunay(ax, pixel_values, mapper, norm, colormap)
-+
-+ # --- overlays --------------------------------------------------------------
-+ if lines is not None:
-+ for line in lines:
-+ if line is not None and len(line) > 0:
-+ ax.plot(line[:, 1], line[:, 0], linewidth=2)
-+
-+ if grid is not None:
-+ ax.scatter(grid[:, 1], grid[:, 0], s=1, c="w", alpha=0.5)
-+
-+ apply_extent(ax, extent)
-+
-+ ax.set_title(title, fontsize=16)
-+ ax.set_xlabel(xlabel, fontsize=14)
-+ ax.set_ylabel(ylabel, fontsize=14)
-+ ax.tick_params(labelsize=12)
-+
-+ if owns_figure:
-+ save_figure(
-+ fig,
-+ path=output_path or "",
-+ filename=output_filename,
-+ format=output_format,
-+ )
-+
-+
-+def _plot_rectangular(ax, pixel_values, mapper, norm, colormap, extent):
-+ """Render a rectangular mesh reconstruction with pcolormesh or imshow."""
-+ from autoarray.inversion.mesh.interpolator.rectangular_uniform import (
-+ InterpolatorRectangularUniform,
-+ )
-+ import numpy as np
-+
-+ shape_native = mapper.mesh_geometry.shape
-+
-+ if isinstance(mapper.interpolator, InterpolatorRectangularUniform):
-+ from autoarray.structures.arrays.uniform_2d import Array2D
-+ from autoarray.structures.arrays import array_2d_util
-+
-+ solution_array_2d = array_2d_util.array_2d_native_from(
-+ array_2d_slim=pixel_values,
-+ mask_2d=np.full(fill_value=False, shape=shape_native),
-+ )
-+ pix_array = Array2D.no_mask(
-+ values=solution_array_2d,
-+ pixel_scales=mapper.mesh_geometry.pixel_scales,
-+ origin=mapper.mesh_geometry.origin,
-+ )
-+ ax.imshow(
-+ pix_array.native.array,
-+ cmap=colormap,
-+ norm=norm,
-+ extent=pix_array.geometry.extent,
-+ aspect="auto",
-+ origin="upper",
-+ )
-+ else:
-+ y_edges, x_edges = mapper.mesh_geometry.edges_transformed.T
-+ Y, X = np.meshgrid(y_edges, x_edges, indexing="ij")
-+ im = ax.pcolormesh(
-+ X, Y,
-+ pixel_values.reshape(shape_native),
-+ shading="flat",
-+ norm=norm,
-+ cmap=colormap,
-+ )
-+ plt.colorbar(im, ax=ax)
-+
-+
-+def _plot_delaunay(ax, pixel_values, mapper, norm, colormap):
-+ """Render a Delaunay mesh reconstruction with tripcolor."""
-+ mesh_grid = mapper.source_plane_mesh_grid
-+ x = mesh_grid[:, 1]
-+ y = mesh_grid[:, 0]
-+
-+ if hasattr(pixel_values, "array"):
-+ vals = pixel_values.array
-+ else:
-+ vals = pixel_values
-+
-+ tc = ax.tripcolor(x, y, vals, cmap=colormap, norm=norm, shading="gouraud")
-+ plt.colorbar(tc, ax=ax)
-diff --git a/autoarray/plot/plots/utils.py b/autoarray/plot/plots/utils.py
-new file mode 100644
-index 00000000..4d1cc4f0
---- /dev/null
-+++ b/autoarray/plot/plots/utils.py
-@@ -0,0 +1,96 @@
-+"""
-+Shared utilities for the direct-matplotlib plot functions.
-+"""
-+import logging
-+import os
-+from typing import Optional, Tuple
-+
-+import matplotlib.pyplot as plt
-+import numpy as np
-+
-+logger = logging.getLogger(__name__)
-+
-+
-+def conf_figsize(context: str = "figures") -> Tuple[int, int]:
-+ """
-+ Read figsize from ``visualize/general.yaml`` for the given context.
-+
-+ Parameters
-+ ----------
-+ context
-+ Either ``"figures"`` (single-panel) or ``"subplots"`` (multi-panel).
-+ """
-+ try:
-+ from autonerves import conf
-+
-+ return tuple(conf.instance["visualize"]["general"][context]["figsize"])
-+ except Exception:
-+ return (7, 7) if context == "figures" else (19, 16)
-+
-+
-+def save_figure(
-+ fig: plt.Figure,
-+ path: str,
-+ filename: str,
-+ format: str = "png",
-+ dpi: int = 300,
-+) -> None:
-+ """
-+ Save *fig* to ``/.`` then close it.
-+
-+ If *path* is an empty string or ``None``, ``plt.show()`` is called instead.
-+ After either action ``plt.close(fig)`` is always called to free memory.
-+
-+ Parameters
-+ ----------
-+ fig
-+ The matplotlib figure to save.
-+ path
-+ Directory where the file is written. Created if it does not exist.
-+ filename
-+ File name without extension.
-+ format
-+ File format passed to ``fig.savefig`` (e.g. ``"png"``, ``"pdf"``).
-+ dpi
-+ Resolution in dots per inch.
-+ """
-+ if path:
-+ os.makedirs(path, exist_ok=True)
-+ try:
-+ fig.savefig(
-+ os.path.join(path, f"{filename}.{format}"),
-+ dpi=dpi,
-+ bbox_inches="tight",
-+ pad_inches=0.1,
-+ )
-+ except Exception as exc:
-+ logger.warning(f"save_figure: could not save {filename}.{format}: {exc}")
-+ else:
-+ plt.show()
-+
-+ plt.close(fig)
-+
-+
-+def apply_extent(
-+ ax: plt.Axes,
-+ extent: Tuple[float, float, float, float],
-+ n_ticks: int = 3,
-+) -> None:
-+ """
-+ Apply axis limits and evenly spaced linear ticks to *ax*.
-+
-+ Parameters
-+ ----------
-+ ax
-+ The matplotlib axes to configure.
-+ extent
-+ ``[xmin, xmax, ymin, ymax]`` limits.
-+ n_ticks
-+ Number of ticks on each axis. ``3`` produces ``[-R, 0, R]`` for
-+ a symmetric extent, matching the reference ``plot_grid`` example.
-+ """
-+ xmin, xmax, ymin, ymax = extent
-+ ax.set_xlim(xmin, xmax)
-+ ax.set_ylim(ymin, ymax)
-+ ax.set_xticks(np.linspace(xmin, xmax, n_ticks))
-+ ax.set_yticks(np.linspace(ymin, ymax, n_ticks))
-diff --git a/autoarray/plot/plots/yx.py b/autoarray/plot/plots/yx.py
-new file mode 100644
-index 00000000..383c75e5
---- /dev/null
-+++ b/autoarray/plot/plots/yx.py
-@@ -0,0 +1,131 @@
-+"""
-+Standalone function for plotting 1D y-vs-x data.
-+
-+Replaces ``MatPlot1D.plot_yx`` / ``MatWrap`` system.
-+"""
-+from typing import List, Optional, Tuple
-+
-+import matplotlib.pyplot as plt
-+import numpy as np
-+
-+from autoarray.plot.plots.utils import conf_figsize, save_figure
-+
-+
-+def plot_yx(
-+ y: np.ndarray,
-+ x: Optional[np.ndarray] = None,
-+ ax: Optional[plt.Axes] = None,
-+ # --- errors / extras --------------------------------------------------------
-+ y_errors: Optional[np.ndarray] = None,
-+ x_errors: Optional[np.ndarray] = None,
-+ y_extra: Optional[np.ndarray] = None,
-+ shaded_region: Optional[Tuple[np.ndarray, np.ndarray]] = None,
-+ # --- cosmetics --------------------------------------------------------------
-+ title: str = "",
-+ xlabel: str = "",
-+ ylabel: str = "",
-+ label: Optional[str] = None,
-+ color: str = "b",
-+ linestyle: str = "-",
-+ plot_axis_type: str = "linear",
-+ # --- figure control (used only when ax is None) -----------------------------
-+ figsize: Optional[Tuple[int, int]] = None,
-+ output_path: Optional[str] = None,
-+ output_filename: str = "yx",
-+ output_format: str = "png",
-+) -> None:
-+ """
-+ Plot 1D y versus x data.
-+
-+ Replaces ``MatPlot1D.plot_yx`` with direct matplotlib calls.
-+
-+ Parameters
-+ ----------
-+ y
-+ 1D numpy array of y values.
-+ x
-+ 1D numpy array of x values. When ``None`` integer indices are used.
-+ ax
-+ Existing ``Axes`` to draw onto. ``None`` creates a new figure.
-+ y_errors, x_errors
-+ Per-point error values; trigger ``plt.errorbar``.
-+ y_extra
-+ Optional second y series to overlay.
-+ shaded_region
-+ Tuple ``(y1, y2)`` arrays; filled region drawn with alpha.
-+ title
-+ Figure title.
-+ xlabel, ylabel
-+ Axis labels.
-+ label
-+ Legend label for the main series.
-+ color
-+ Line / marker colour.
-+ linestyle
-+ Line style string.
-+ plot_axis_type
-+ One of ``"linear"``, ``"log"``, ``"loglog"``, ``"symlog"``.
-+ figsize
-+ Figure size in inches.
-+ output_path
-+ Directory for saving. Empty / ``None`` calls ``plt.show()``.
-+ output_filename
-+ Base file name without extension.
-+ output_format
-+ File format, e.g. ``"png"``.
-+ """
-+ # guard: nothing to draw
-+ if y is None or np.count_nonzero(y) == 0 or np.isnan(y).all():
-+ return
-+
-+ owns_figure = ax is None
-+ if owns_figure:
-+ figsize = figsize or conf_figsize("figures")
-+ fig, ax = plt.subplots(1, 1, figsize=figsize)
-+ else:
-+ fig = ax.get_figure()
-+
-+ if x is None:
-+ x = np.arange(len(y))
-+
-+ # --- main line / scatter ---------------------------------------------------
-+ if y_errors is not None or x_errors is not None:
-+ ax.errorbar(
-+ x, y, yerr=y_errors, xerr=x_errors,
-+ fmt="-o", color=color, label=label, markersize=3,
-+ )
-+ elif plot_axis_type in ("log", "semilogy"):
-+ ax.semilogy(x, y, color=color, linestyle=linestyle, label=label)
-+ elif plot_axis_type == "loglog":
-+ ax.loglog(x, y, color=color, linestyle=linestyle, label=label)
-+ else:
-+ ax.plot(x, y, color=color, linestyle=linestyle, label=label)
-+
-+ if plot_axis_type == "symlog":
-+ ax.set_yscale("symlog")
-+
-+ # --- extras ----------------------------------------------------------------
-+ if y_extra is not None:
-+ ax.plot(x, y_extra, color="r", linestyle="--", alpha=0.7)
-+
-+ if shaded_region is not None:
-+ y1, y2 = shaded_region
-+ ax.fill_between(x, y1, y2, alpha=0.3)
-+
-+ # --- labels ----------------------------------------------------------------
-+ ax.set_title(title, fontsize=16)
-+ ax.set_xlabel(xlabel, fontsize=14)
-+ ax.set_ylabel(ylabel, fontsize=14)
-+ ax.tick_params(labelsize=12)
-+
-+ if label is not None:
-+ ax.legend(fontsize=12)
-+
-+ # --- output ----------------------------------------------------------------
-+ if owns_figure:
-+ save_figure(
-+ fig,
-+ path=output_path or "",
-+ filename=output_filename,
-+ format=output_format,
-+ )
---
-2.43.0
-
diff --git a/patches/autoarray/0002-PR-A2-A3-Switch-all-autoarray-plotters-to-use-direct.patch b/patches/autoarray/0002-PR-A2-A3-Switch-all-autoarray-plotters-to-use-direct.patch
deleted file mode 100644
index 8e5f3d3acc..0000000000
--- a/patches/autoarray/0002-PR-A2-A3-Switch-all-autoarray-plotters-to-use-direct.patch
+++ /dev/null
@@ -1,1033 +0,0 @@
-From 9c1ab66b47873a906733f393d04e87ea25254c49 Mon Sep 17 00:00:00 2001
-From: Claude
-Date: Mon, 16 Mar 2026 14:19:37 +0000
-Subject: [PATCH 2/3] PR A2+A3: Switch all autoarray plotters to use
- direct-matplotlib functions
-
-Array2DPlotter, Grid2DPlotter, YX1DPlotter (structure_plotters.py):
-- figure_2d() / figure_1d() now call plot_array() / plot_grid() / plot_yx()
-- Subplot mode bridged: setup_subplot() positions the panel, ax passed to plot fn
-- Overlay data extracted from Visuals2D to typed numpy arrays via helpers
-- _output_for_mat_plot() bridges mat_plot.output to path/filename/format args
-
-ImagingMeta (imaging_plotters.py):
-- figures_2d() uses new _plot_array() helper calling plot_array() directly
-- subplot_dataset() unchanged: open/close subplot still via old mechanism
-
-MapperPlotter (mapper_plotters.py):
-- figure_2d(), figure_2d_image(), plot_source_from() use plot_inversion_reconstruction()
- and plot_array() respectively
-
-InversionPlotter (inversion_plotters.py):
-- Added _plot_array() helper; all mat_plot_2d.plot_array() calls replaced
-
-All integration tests pass.
-
-https://claude.ai/code/session_01CzJBy8KvFXiNchoNdk5i9k
----
- autoarray/dataset/plot/imaging_plotters.py | 192 ++++--------
- .../inversion/plot/inversion_plotters.py | 113 +++----
- autoarray/inversion/plot/mapper_plotters.py | 157 +++++-----
- .../structures/plot/structure_plotters.py | 277 +++++++++++-------
- 4 files changed, 374 insertions(+), 365 deletions(-)
-
-diff --git a/autoarray/dataset/plot/imaging_plotters.py b/autoarray/dataset/plot/imaging_plotters.py
-index ac1f23de..afc2cff5 100644
---- a/autoarray/dataset/plot/imaging_plotters.py
-+++ b/autoarray/dataset/plot/imaging_plotters.py
-@@ -1,10 +1,19 @@
- import copy
-+import numpy as np
- from typing import Callable, Optional
-
- from autoarray.plot.visuals.two_d import Visuals2D
- from autoarray.plot.mat_plot.two_d import MatPlot2D
- from autoarray.plot.auto_labels import AutoLabels
- from autoarray.plot.abstract_plotters import AbstractPlotter
-+from autoarray.plot.plots.array import plot_array
-+from autoarray.structures.plot.structure_plotters import (
-+ _lines_from_visuals,
-+ _positions_from_visuals,
-+ _mask_edge_from,
-+ _grid_from_visuals,
-+ _output_for_mat_plot,
-+)
- from autoarray.dataset.imaging.dataset import Imaging
-
-
-@@ -15,35 +24,49 @@ class ImagingMeta(AbstractPlotter):
- mat_plot_2d: MatPlot2D = None,
- visuals_2d: Visuals2D = None,
- ):
-- """
-- Plots the attributes of `Imaging` objects using the matplotlib method `imshow()` and many other matplotlib
-- functions which customize the plot's appearance.
--
-- The `mat_plot_2d` attribute wraps matplotlib function calls to make the figure. By default, the settings
-- passed to every matplotlib function called are those specified in the `config/visualize/mat_wrap/*.ini` files,
-- but a user can manually input values into `MatPlot2d` to customize the figure's appearance.
--
-- Overlaid on the figure are visuals, contained in the `Visuals2D` object. Attributes may be extracted from
-- the `Imaging` and plotted via the visuals object.
--
-- Parameters
-- ----------
-- dataset
-- The imaging dataset the plotter plots.
-- mat_plot_2d
-- Contains objects which wrap the matplotlib function calls that make 2D plots.
-- visuals_2d
-- Contains 2D visuals that can be overlaid on 2D plots.
-- """
--
- super().__init__(mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d)
--
- self.dataset = dataset
-
- @property
- def imaging(self):
- return self.dataset
-
-+ def _plot_array(self, array, auto_filename: str, title: str, ax=None):
-+ """Internal helper: plot an Array2D via plot_array()."""
-+ if array is None:
-+ return
-+
-+ is_sub = self.mat_plot_2d.is_for_subplot
-+ if ax is None:
-+ ax = self.mat_plot_2d.setup_subplot() if is_sub else None
-+
-+ output_path, filename, fmt = _output_for_mat_plot(
-+ self.mat_plot_2d, is_sub, auto_filename
-+ )
-+
-+ try:
-+ arr = array.native.array
-+ extent = array.geometry.extent
-+ except AttributeError:
-+ arr = np.asarray(array)
-+ extent = None
-+
-+ plot_array(
-+ array=arr,
-+ ax=ax,
-+ extent=extent,
-+ mask=_mask_edge_from(array if hasattr(array, "mask") else None, self.visuals_2d),
-+ grid=_grid_from_visuals(self.visuals_2d),
-+ positions=_positions_from_visuals(self.visuals_2d),
-+ lines=_lines_from_visuals(self.visuals_2d),
-+ title=title,
-+ colormap=self.mat_plot_2d.cmap.cmap,
-+ use_log10=self.mat_plot_2d.use_log10,
-+ output_path=output_path,
-+ output_filename=filename,
-+ output_format=fmt,
-+ )
-+
- def figures_2d(
- self,
- data: bool = False,
-@@ -54,86 +77,47 @@ class ImagingMeta(AbstractPlotter):
- over_sample_size_pixelization: bool = False,
- title_str: Optional[str] = None,
- ):
-- """
-- Plots the individual attributes of the plotter's `Imaging` object in 2D.
--
-- The API is such that every plottable attribute of the `Imaging` object is an input parameter of type bool of
-- the function, which if switched to `True` means that it is plotted.
--
-- Parameters
-- ----------
-- data
-- Whether to make a 2D plot (via `imshow`) of the image data.
-- noise_map
-- Whether to make a 2D plot (via `imshow`) of the noise map.
-- psf
-- Whether to make a 2D plot (via `imshow`) of the psf.
-- signal_to_noise_map
-- Whether to make a 2D plot (via `imshow`) of the signal-to-noise map.
-- over_sample_size_lp
-- Whether to make a 2D plot (via `imshow`) of the Over Sampling for input light profiles. If
-- adaptive sub size is used, the sub size grid for a centre of (0.0, 0.0) is used.
-- over_sample_size_pixelization
-- Whether to make a 2D plot (via `imshow`) of the Over Sampling for pixelizations.
-- """
--
- if data:
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.dataset.data,
-- visuals_2d=self.visuals_2d,
-- auto_labels=AutoLabels(title=title_str or f" Data", filename="data"),
-+ auto_filename="data",
-+ title=title_str or "Data",
- )
-
- if noise_map:
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.dataset.noise_map,
-- visuals_2d=self.visuals_2d,
-- auto_labels=AutoLabels(title_str or f"Noise-Map", filename="noise_map"),
-+ auto_filename="noise_map",
-+ title=title_str or "Noise-Map",
- )
-
- if psf:
- if self.dataset.psf is not None:
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.dataset.psf.kernel,
-- visuals_2d=self.visuals_2d,
-- auto_labels=AutoLabels(
-- title=title_str or f"Point Spread Function",
-- filename="psf",
-- cb_unit="",
-- ),
-+ auto_filename="psf",
-+ title=title_str or "Point Spread Function",
- )
-
- if signal_to_noise_map:
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.dataset.signal_to_noise_map,
-- visuals_2d=self.visuals_2d,
-- auto_labels=AutoLabels(
-- title=title_str or f"Signal-To-Noise Map",
-- filename="signal_to_noise_map",
-- cb_unit="",
-- ),
-+ auto_filename="signal_to_noise_map",
-+ title=title_str or "Signal-To-Noise Map",
- )
-
- if over_sample_size_lp:
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.dataset.grids.over_sample_size_lp,
-- visuals_2d=self.visuals_2d,
-- auto_labels=AutoLabels(
-- title=title_str or f"Over Sample Size (Light Profiles)",
-- filename="over_sample_size_lp",
-- cb_unit="",
-- ),
-+ auto_filename="over_sample_size_lp",
-+ title=title_str or "Over Sample Size (Light Profiles)",
- )
-
- if over_sample_size_pixelization:
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.dataset.grids.over_sample_size_pixelization,
-- visuals_2d=self.visuals_2d,
-- auto_labels=AutoLabels(
-- title=title_str or f"Over Sample Size (Pixelization)",
-- filename="over_sample_size_pixelization",
-- cb_unit="",
-- ),
-+ auto_filename="over_sample_size_pixelization",
-+ title=title_str or "Over Sample Size (Pixelization)",
- )
-
- def subplot(
-@@ -146,30 +130,6 @@ class ImagingMeta(AbstractPlotter):
- over_sampling_pixelization: bool = False,
- auto_filename: str = "subplot_dataset",
- ):
-- """
-- Plots the individual attributes of the plotter's `Imaging` object in 2D on a subplot.
--
-- The API is such that every plottable attribute of the `Imaging` object is an input parameter of type bool of
-- the function, which if switched to `True` means that it is included on the subplot.
--
-- Parameters
-- ----------
-- data
-- Whether to include a 2D plot (via `imshow`) of the image data.
-- noise_map
-- Whether to include a 2D plot (via `imshow`) of the noise map.
-- psf
-- Whether to include a 2D plot (via `imshow`) of the psf.
-- signal_to_noise_map
-- Whether to include a 2D plot (via `imshow`) of the signal-to-noise map.
-- over_sampling
-- Whether to include a 2D plot (via `imshow`) of the Over Sampling. If adaptive sub size is used, the
-- sub size grid for a centre of (0.0, 0.0) is used.
-- over_sampling_pixelization
-- Whether to include a 2D plot (via `imshow`) of the Over Sampling for pixelizations.
-- auto_filename
-- The default filename of the output subplot if written to hard-disk.
-- """
- self._subplot_custom_plot(
- data=data,
- noise_map=noise_map,
-@@ -181,9 +141,6 @@ class ImagingMeta(AbstractPlotter):
- )
-
- def subplot_dataset(self):
-- """
-- Standard subplot of the attributes of the plotter's `Imaging` object.
-- """
- use_log10_original = self.mat_plot_2d.use_log10
-
- self.open_subplot_figure(number_subplots=9)
-@@ -199,7 +156,6 @@ class ImagingMeta(AbstractPlotter):
- self.mat_plot_2d.contour = contour_original
-
- self.figures_2d(noise_map=True)
--
- self.figures_2d(psf=True)
-
- self.mat_plot_2d.use_log10 = True
-@@ -207,7 +163,6 @@ class ImagingMeta(AbstractPlotter):
- self.mat_plot_2d.use_log10 = False
-
- self.figures_2d(signal_to_noise_map=True)
--
- self.figures_2d(over_sample_size_lp=True)
- self.figures_2d(over_sample_size_pixelization=True)
-
-@@ -224,27 +179,6 @@ class Imaging(AbstractPlotter):
- mat_plot_2d: MatPlot2D = None,
- visuals_2d: Visuals2D = None,
- ):
-- """
-- Plots the attributes of `Imaging` objects using the matplotlib method `imshow()` and many other matplotlib
-- functions which customize the plot's appearance.
--
-- The `mat_plot_2d` attribute wraps matplotlib function calls to make the figure. By default, the settings
-- passed to every matplotlib function called are those specified in the `config/visualize/mat_wrap/*.ini` files,
-- but a user can manually input values into `MatPlot2d` to customize the figure's appearance.
--
-- Overlaid on the figure are visuals, contained in the `Visuals2D` object. Attributes may be extracted from
-- the `Imaging` and plotted via the visuals object.
--
-- Parameters
-- ----------
-- imaging
-- The imaging dataset the plotter plots.
-- mat_plot_2d
-- Contains objects which wrap the matplotlib function calls that make 2D plots.
-- visuals_2d
-- Contains 2D visuals that can be overlaid on 2D plots.
-- """
--
- super().__init__(mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d)
-
- self.dataset = dataset
-diff --git a/autoarray/inversion/plot/inversion_plotters.py b/autoarray/inversion/plot/inversion_plotters.py
-index ef2ae6ea..586eabc7 100644
---- a/autoarray/inversion/plot/inversion_plotters.py
-+++ b/autoarray/inversion/plot/inversion_plotters.py
-@@ -7,9 +7,17 @@ from autoarray.plot.abstract_plotters import AbstractPlotter
- from autoarray.plot.visuals.two_d import Visuals2D
- from autoarray.plot.mat_plot.two_d import MatPlot2D
- from autoarray.plot.auto_labels import AutoLabels
-+from autoarray.plot.plots.array import plot_array
- from autoarray.structures.arrays.uniform_2d import Array2D
- from autoarray.inversion.inversion.abstract import AbstractInversion
- from autoarray.inversion.plot.mapper_plotters import MapperPlotter
-+from autoarray.structures.plot.structure_plotters import (
-+ _lines_from_visuals,
-+ _mask_edge_from,
-+ _grid_from_visuals,
-+ _positions_from_visuals,
-+ _output_for_mat_plot,
-+)
-
-
- class InversionPlotter(AbstractPlotter):
-@@ -66,35 +74,53 @@ class InversionPlotter(AbstractPlotter):
- visuals_2d=self.visuals_2d,
- )
-
-+ def _plot_array(self, array, auto_filename: str, title: str):
-+ """Helper: plot an Array2D using the new direct-matplotlib function."""
-+ is_sub = self.mat_plot_2d.is_for_subplot
-+ ax = self.mat_plot_2d.setup_subplot() if is_sub else None
-+ output_path, filename, fmt = _output_for_mat_plot(
-+ self.mat_plot_2d, is_sub, auto_filename
-+ )
-+ try:
-+ arr = array.native.array
-+ extent = array.geometry.extent
-+ mask_overlay = _mask_edge_from(array, self.visuals_2d)
-+ except AttributeError:
-+ arr = np.asarray(array)
-+ extent = None
-+ mask_overlay = None
-+ plot_array(
-+ array=arr,
-+ ax=ax,
-+ extent=extent,
-+ mask=mask_overlay,
-+ grid=_grid_from_visuals(self.visuals_2d),
-+ positions=_positions_from_visuals(self.visuals_2d),
-+ lines=_lines_from_visuals(self.visuals_2d),
-+ title=title,
-+ colormap=self.mat_plot_2d.cmap.cmap,
-+ use_log10=self.mat_plot_2d.use_log10,
-+ output_path=output_path,
-+ output_filename=filename,
-+ output_format=fmt,
-+ )
-+
- def figures_2d(self, reconstructed_operated_data: bool = False):
- """
- Plots the individual attributes of the plotter's `Inversion` object in 2D.
--
-- The API is such that every plottable attribute of the `Inversion` object is an input parameter of type bool of
-- the function, which if switched to `True` means that it is plotted.
--
-- Parameters
-- ----------
-- reconstructed_operated_data
-- Whether to make a 2D plot (via `imshow`) of the reconstructed image data.
- """
- if reconstructed_operated_data:
- try:
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.inversion.mapped_reconstructed_operated_data,
-- visuals_2d=self.visuals_2d,
-- auto_labels=AutoLabels(
-- title="Reconstructed Image",
-- filename="reconstructed_operated_data",
-- ),
-+ auto_filename="reconstructed_operated_data",
-+ title="Reconstructed Image",
- )
- except AttributeError:
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.inversion.mapped_reconstructed_data,
-- visuals_2d=self.visuals_2d,
-- auto_labels=AutoLabels(
-- title="Reconstructed Image", filename="reconstructed_data"
-- ),
-+ auto_filename="reconstructed_data",
-+ title="Reconstructed Image",
- )
-
- def figures_2d_of_pixelization(
-@@ -153,19 +179,13 @@ class InversionPlotter(AbstractPlotter):
- mapper_plotter = self.mapper_plotter_from(mapper_index=pixelization_index)
-
- if data_subtracted:
-- # Attribute error is cause this raises an error for interferometer inversion, because the data is
-- # visibilities not an image. Update this to be handled better in future.
--
-+ # Attribute error is raised for interferometer inversion where data is visibilities not an image.
- try:
- array = self.inversion.data_subtracted_dict[mapper_plotter.mapper]
--
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=array,
-- visuals_2d=self.visuals_2d,
-- grid_indexes=mapper_plotter.mapper.over_sampler.uniform_over_sampled,
-- auto_labels=AutoLabels(
-- title="Data Subtracted", filename="data_subtracted"
-- ),
-+ auto_filename="data_subtracted",
-+ title="Data Subtracted",
- )
- except AttributeError:
- pass
-@@ -182,13 +202,10 @@ class InversionPlotter(AbstractPlotter):
- mapper_plotter.mapper
- ]
-
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=array,
-- visuals_2d=self.visuals_2d,
-- grid_indexes=mapper_plotter.mapper.over_sampler.uniform_over_sampled,
-- auto_labels=AutoLabels(
-- title="Reconstructed Image", filename="reconstructed_operated_data"
-- ),
-+ auto_filename="reconstructed_operated_data",
-+ title="Reconstructed Image",
- )
-
- if reconstruction:
-@@ -271,29 +288,19 @@ class InversionPlotter(AbstractPlotter):
- values=mapper_plotter.mapper.over_sampler.sub_size,
- mask=self.inversion.dataset.mask,
- )
--
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=sub_size,
-- visuals_2d=self.visuals_2d,
-- auto_labels=AutoLabels(
-- title="Sub Pixels Per Image Pixels",
-- filename="sub_pixels_per_image_pixels",
-- ),
-+ auto_filename="sub_pixels_per_image_pixels",
-+ title="Sub Pixels Per Image Pixels",
- )
-
- if mesh_pixels_per_image_pixels:
- try:
-- mesh_pixels_per_image_pixels = (
-- mapper_plotter.mapper.mesh_pixels_per_image_pixels
-- )
--
-- self.mat_plot_2d.plot_array(
-- array=mesh_pixels_per_image_pixels,
-- visuals_2d=self.visuals_2d,
-- auto_labels=AutoLabels(
-- title="Mesh Pixels Per Image Pixels",
-- filename="mesh_pixels_per_image_pixels",
-- ),
-+ mesh_arr = mapper_plotter.mapper.mesh_pixels_per_image_pixels
-+ self._plot_array(
-+ array=mesh_arr,
-+ auto_filename="mesh_pixels_per_image_pixels",
-+ title="Mesh Pixels Per Image Pixels",
- )
- except Exception:
- pass
-diff --git a/autoarray/inversion/plot/mapper_plotters.py b/autoarray/inversion/plot/mapper_plotters.py
-index b9a44679..47617e1e 100644
---- a/autoarray/inversion/plot/mapper_plotters.py
-+++ b/autoarray/inversion/plot/mapper_plotters.py
-@@ -1,12 +1,20 @@
- import numpy as np
-+import logging
-
- from autoarray.plot.abstract_plotters import AbstractPlotter
- from autoarray.plot.visuals.two_d import Visuals2D
- from autoarray.plot.mat_plot.two_d import MatPlot2D
- from autoarray.plot.auto_labels import AutoLabels
-+from autoarray.plot.plots.inversion import plot_inversion_reconstruction
-+from autoarray.plot.plots.array import plot_array
- from autoarray.structures.arrays.uniform_2d import Array2D
--
--import logging
-+from autoarray.structures.plot.structure_plotters import (
-+ _lines_from_visuals,
-+ _positions_from_visuals,
-+ _mask_edge_from,
-+ _grid_from_visuals,
-+ _output_for_mat_plot,
-+)
-
- logger = logging.getLogger(__name__)
-
-@@ -18,80 +26,70 @@ class MapperPlotter(AbstractPlotter):
- mat_plot_2d: MatPlot2D = None,
- visuals_2d: Visuals2D = None,
- ):
-- """
-- Plots the attributes of `Mapper` objects using the matplotlib method `imshow()` and many other matplotlib
-- functions which customize the plot's appearance.
--
-- The `mat_plot_2d` attribute wraps matplotlib function calls to make the figure. By default, the settings
-- passed to every matplotlib function called are those specified in the `config/visualize/mat_wrap/*.ini` files,
-- but a user can manually input values into `MatPlot2d` to customize the figure's appearance.
--
-- Overlaid on the figure are visuals, contained in the `Visuals2D` object. Attributes may be extracted from
-- the `Mapper` and plotted via the visuals object.
--
-- Parameters
-- ----------
-- mapper
-- The mapper the plotter plots.
-- mat_plot_2d
-- Contains objects which wrap the matplotlib function calls that make 2D plots.
-- visuals_2d
-- Contains 2D visuals that can be overlaid on 2D plots.
-- """
- super().__init__(visuals_2d=visuals_2d, mat_plot_2d=mat_plot_2d)
--
- self.mapper = mapper
-
-- def figure_2d(self, solution_vector: bool = None):
-- """
-- Plots the plotter's `Mapper` object in 2D.
-+ def figure_2d(self, solution_vector=None):
-+ """Plot the mapper's source-plane reconstruction."""
-+ is_sub = self.mat_plot_2d.is_for_subplot
-+ ax = self.mat_plot_2d.setup_subplot() if is_sub else None
-
-- Parameters
-- ----------
-- solution_vector
-- A vector of values which can culor the pixels of the mapper's source pixels.
-- """
-- self.mat_plot_2d.plot_mapper(
-- mapper=self.mapper,
-- visuals_2d=self.visuals_2d,
-- pixel_values=solution_vector,
-- auto_labels=AutoLabels(
-- title="Pixelization Mesh (Source-Plane)", filename="mapper"
-- ),
-+ output_path, filename, fmt = _output_for_mat_plot(
-+ self.mat_plot_2d, is_sub, "mapper"
- )
-
-+ try:
-+ plot_inversion_reconstruction(
-+ pixel_values=solution_vector,
-+ mapper=self.mapper,
-+ ax=ax,
-+ title="Pixelization Mesh (Source-Plane)",
-+ colormap=self.mat_plot_2d.cmap.cmap,
-+ use_log10=self.mat_plot_2d.use_log10,
-+ lines=_lines_from_visuals(self.visuals_2d),
-+ output_path=output_path,
-+ output_filename=filename,
-+ output_format=fmt,
-+ )
-+ except Exception as exc:
-+ logger.info(
-+ f"Could not plot the source-plane via the Mapper: {exc}"
-+ )
-+
- def figure_2d_image(self, image):
-+ """Plot an image-plane representation of the mapper."""
-+ is_sub = self.mat_plot_2d.is_for_subplot
-+ ax = self.mat_plot_2d.setup_subplot() if is_sub else None
-
-- self.mat_plot_2d.plot_array(
-- array=image,
-- visuals_2d=self.visuals_2d,
-- grid_indexes=self.mapper.image_plane_data_grid.over_sampled,
-- auto_labels=AutoLabels(
-- title="Image (Image-Plane)", filename="mapper_image"
-- ),
-+ output_path, filename, fmt = _output_for_mat_plot(
-+ self.mat_plot_2d, is_sub, "mapper_image"
- )
-
-- def subplot_image_and_mapper(
-- self,
-- image: Array2D,
-- ):
-- """
-- Make a subplot of an input image and the `Mapper`'s source-plane reconstruction.
--
-- This function can include colored points that mark the mappings between the image pixels and their
-- corresponding locations in the `Mapper` source-plane and reconstruction. This therefore visually illustrates
-- the mapping process.
-+ try:
-+ arr = image.native.array
-+ extent = image.geometry.extent
-+ except AttributeError:
-+ arr = np.asarray(image)
-+ extent = None
-+
-+ plot_array(
-+ array=arr,
-+ ax=ax,
-+ extent=extent,
-+ mask=_mask_edge_from(image if hasattr(image, "mask") else None, self.visuals_2d),
-+ lines=_lines_from_visuals(self.visuals_2d),
-+ title="Image (Image-Plane)",
-+ colormap=self.mat_plot_2d.cmap.cmap,
-+ use_log10=self.mat_plot_2d.use_log10,
-+ output_path=output_path,
-+ output_filename=filename,
-+ output_format=fmt,
-+ )
-
-- Parameters
-- ----------
-- image
-- The image which is plotted on the subplot.
-- """
-+ def subplot_image_and_mapper(self, image: Array2D):
- self.open_subplot_figure(number_subplots=2)
--
- self.figure_2d_image(image=image)
- self.figure_2d()
--
- self.mat_plot_2d.output.subplot_to_figure(
- auto_filename="subplot_image_and_mapper"
- )
-@@ -103,26 +101,29 @@ class MapperPlotter(AbstractPlotter):
- zoom_to_brightest: bool = True,
- auto_labels: AutoLabels = AutoLabels(),
- ):
-- """
-- Plot the source of the `Mapper` where the coloring is specified by an input set of values.
-+ """Plot mapper source coloured by pixel_values."""
-+ is_sub = self.mat_plot_2d.is_for_subplot
-+ ax = self.mat_plot_2d.setup_subplot() if is_sub else None
-+
-+ output_path, filename, fmt = _output_for_mat_plot(
-+ self.mat_plot_2d,
-+ is_sub,
-+ auto_labels.filename or "reconstruction",
-+ )
-
-- Parameters
-- ----------
-- pixel_values
-- The values of the mapper's source pixels used for coloring the figure.
-- zoom_to_brightest
-- For images not in the image-plane (e.g. the `plane_image`), whether to automatically zoom the plot to
-- the brightest regions of the galaxies being plotted as opposed to the full extent of the grid.
-- auto_labels
-- The labels given to the figure.
-- """
- try:
-- self.mat_plot_2d.plot_mapper(
-- mapper=self.mapper,
-- visuals_2d=self.visuals_2d,
-- auto_labels=auto_labels,
-+ plot_inversion_reconstruction(
- pixel_values=pixel_values,
-+ mapper=self.mapper,
-+ ax=ax,
-+ title=auto_labels.title or Source Plane (Zoom),
-+ colormap=self.mat_plot_2d.cmap.cmap,
-+ use_log10=self.mat_plot_2d.use_log10,
- zoom_to_brightest=zoom_to_brightest,
-+ lines=_lines_from_visuals(self.visuals_2d),
-+ output_path=output_path,
-+ output_filename=filename,
-+ output_format=fmt,
- )
- except ValueError:
- logger.info(
-diff --git a/autoarray/structures/plot/structure_plotters.py b/autoarray/structures/plot/structure_plotters.py
-index 7e7cf655..e05c19f9 100644
---- a/autoarray/structures/plot/structure_plotters.py
-+++ b/autoarray/structures/plot/structure_plotters.py
-@@ -7,12 +7,115 @@ from autoarray.plot.visuals.two_d import Visuals2D
- from autoarray.plot.mat_plot.one_d import MatPlot1D
- from autoarray.plot.mat_plot.two_d import MatPlot2D
- from autoarray.plot.auto_labels import AutoLabels
-+from autoarray.plot.plots.array import plot_array
-+from autoarray.plot.plots.grid import plot_grid
-+from autoarray.plot.plots.yx import plot_yx
- from autoarray.structures.arrays.uniform_1d import Array1D
- from autoarray.structures.arrays.uniform_2d import Array2D
- from autoarray.structures.grids.uniform_1d import Grid1D
- from autoarray.structures.grids.uniform_2d import Grid2D
-
-
-+# ---------------------------------------------------------------------------
-+# Helpers to extract plain numpy overlay data from Visuals2D/Visuals1D
-+# ---------------------------------------------------------------------------
-+
-+def _lines_from_visuals(visuals_2d: Visuals2D) -> Optional[List[np.ndarray]]:
-+ """Return a list of (N, 2) numpy arrays from visuals_2d.lines."""
-+ if visuals_2d is None or visuals_2d.lines is None:
-+ return None
-+ lines = visuals_2d.lines
-+ result = []
-+ try:
-+ # Grid2DIrregular or list of array-like objects
-+ for line in lines:
-+ try:
-+ arr = np.array(line.array if hasattr(line, "array") else line)
-+ if arr.ndim == 2 and arr.shape[1] == 2:
-+ result.append(arr)
-+ except Exception:
-+ pass
-+ except TypeError:
-+ pass
-+ return result or None
-+
-+
-+def _positions_from_visuals(visuals_2d: Visuals2D) -> Optional[List[np.ndarray]]:
-+ """Return a list of (N, 2) numpy arrays from visuals_2d.positions."""
-+ if visuals_2d is None or visuals_2d.positions is None:
-+ return None
-+ positions = visuals_2d.positions
-+ try:
-+ arr = np.array(positions.array if hasattr(positions, "array") else positions)
-+ if arr.ndim == 2 and arr.shape[1] == 2:
-+ return [arr]
-+ except Exception:
-+ pass
-+ if isinstance(positions, list):
-+ result = []
-+ for p in positions:
-+ try:
-+ arr = np.array(p.array if hasattr(p, "array") else p)
-+ result.append(arr)
-+ except Exception:
-+ pass
-+ return result or None
-+ return None
-+
-+
-+def _mask_edge_from(array: Array2D, visuals_2d: Optional[Visuals2D]) -> Optional[np.ndarray]:
-+ """Return edge-pixel coordinates to scatter as mask overlay."""
-+ if visuals_2d is not None and visuals_2d.mask is not None:
-+ try:
-+ return np.array(visuals_2d.mask.derive_grid.edge.array)
-+ except Exception:
-+ pass
-+ if array is not None and not array.mask.is_all_false:
-+ try:
-+ return np.array(array.mask.derive_grid.edge.array)
-+ except Exception:
-+ pass
-+ return None
-+
-+
-+def _grid_from_visuals(visuals_2d: Visuals2D) -> Optional[np.ndarray]:
-+ """Return grid scatter coordinates from visuals_2d.grid."""
-+ if visuals_2d is None or visuals_2d.grid is None:
-+ return None
-+ grid = visuals_2d.grid
-+ try:
-+ return np.array(grid.array if hasattr(grid, "array") else grid)
-+ except Exception:
-+ return None
-+
-+
-+def _output_for_mat_plot(mat_plot, is_for_subplot: bool, auto_filename: str):
-+ """
-+ Derive (output_path, output_filename, output_format) from a MatPlot object.
-+
-+ When in subplot mode, returns output_path=None so that plot_array does not
-+ save — the subplot is saved later by close_subplot_figure().
-+ """
-+ if is_for_subplot:
-+ return None, auto_filename, "png"
-+
-+ output = mat_plot.output
-+ fmt_list = output.format_list
-+ fmt = fmt_list[0] if fmt_list else "show"
-+
-+ filename = output.filename_from(auto_filename)
-+
-+ if fmt == "show":
-+ return None, filename, "png"
-+
-+ path = output.output_path_from(fmt)
-+ return path, filename, fmt
-+
-+
-+# ---------------------------------------------------------------------------
-+# Plotters
-+# ---------------------------------------------------------------------------
-+
- class Array2DPlotter(AbstractPlotter):
- def __init__(
- self,
-@@ -20,38 +123,35 @@ class Array2DPlotter(AbstractPlotter):
- mat_plot_2d: MatPlot2D = None,
- visuals_2d: Visuals2D = None,
- ):
-- """
-- Plots `Array2D` objects using the matplotlib method `imshow()` and many other matplotlib functions which
-- customize the plot's appearance.
--
-- The `mat_plot_2d` attribute wraps matplotlib function calls to make the figure. By default, the settings
-- passed to every matplotlib function called are those specified in the `config/visualize/mat_wrap/*.ini` files,
-- but a user can manually input values into `MatPlot2d` to customize the figure's appearance.
--
-- Overlaid on the figure are visuals, contained in the `Visuals2D` object. Attributes may be extracted from
-- the `Array2D` and plotted via the visuals object.
--
-- Parameters
-- ----------
-- array
-- The 2D array the plotter plot.
-- mat_plot_2d
-- Contains objects which wrap the matplotlib function calls that make 2D plots.
-- visuals_2d
-- Contains 2D visuals that can be overlaid on 2D plots.
-- """
- super().__init__(visuals_2d=visuals_2d, mat_plot_2d=mat_plot_2d)
--
- self.array = array
-
- def figure_2d(self):
-- """
-- Plots the plotter's `Array2D` object in 2D.
-- """
-- self.mat_plot_2d.plot_array(
-- array=self.array,
-- visuals_2d=self.visuals_2d,
-- auto_labels=AutoLabels(title="Array2D", filename="array"),
-+ """Plot the array as a 2D image."""
-+ if self.array is None or np.all(self.array == 0):
-+ return
-+
-+ is_sub = self.mat_plot_2d.is_for_subplot
-+ ax = self.mat_plot_2d.setup_subplot() if is_sub else None
-+
-+ output_path, filename, fmt = _output_for_mat_plot(
-+ self.mat_plot_2d, is_sub, "array"
-+ )
-+
-+ plot_array(
-+ array=self.array.native.array,
-+ ax=ax,
-+ extent=self.array.geometry.extent,
-+ mask=_mask_edge_from(self.array, self.visuals_2d),
-+ grid=_grid_from_visuals(self.visuals_2d),
-+ positions=_positions_from_visuals(self.visuals_2d),
-+ lines=_lines_from_visuals(self.visuals_2d),
-+ title="Array2D",
-+ colormap=self.mat_plot_2d.cmap.cmap,
-+ use_log10=self.mat_plot_2d.use_log10,
-+ output_path=output_path,
-+ output_filename=filename,
-+ output_format=fmt,
- )
-
-
-@@ -62,28 +162,7 @@ class Grid2DPlotter(AbstractPlotter):
- mat_plot_2d: MatPlot2D = None,
- visuals_2d: Visuals2D = None,
- ):
-- """
-- Plots `Grid2D` objects using the matplotlib method `scatter()` and many other matplotlib functions which
-- customize the plot's appearance.
--
-- The `mat_plot_2d` attribute wraps matplotlib function calls to make the figure. By default, the settings
-- passed to every matplotlib function called are those specified in the `config/visualize/mat_wrap/*.ini` files,
-- but a user can manually input values into `MatPlot2d` to customize the figure's appearance.
--
-- Overlaid on the figure are visuals, contained in the `Visuals2D` object. Attributes may be extracted from
-- the `Grid2D` and plotted via the visuals object.
--
-- Parameters
-- ----------
-- grid
-- The 2D grid the plotter plot.
-- mat_plot_2d
-- Contains objects which wrap the matplotlib function calls that make 2D plots.
-- visuals_2d
-- Contains 2D visuals that can be overlaid on 2D plots.
-- """
- super().__init__(visuals_2d=visuals_2d, mat_plot_2d=mat_plot_2d)
--
- self.grid = grid
-
- def figure_2d(
-@@ -92,27 +171,24 @@ class Grid2DPlotter(AbstractPlotter):
- plot_grid_lines: bool = False,
- plot_over_sampled_grid: bool = False,
- ):
-- """
-- Plots the plotter's `Grid2D` object in 2D.
--
-- Parameters
-- ----------
-- color_array
-- An array of RGB color values which can be used to give the plotted 2D grid a colorscale (w/ colorbar).
-- plot_grid_lines
-- If True, a rectangular grid of lines is plotted on the figure showing the pixels which the grid coordinates
-- are centred on.
-- plot_over_sampled_grid
-- If True, the grid is plotted with over-sampled sub-gridded coordinates based on the `sub_size` attribute
-- of the grid's over-sampling object.
-- """
-- self.mat_plot_2d.plot_grid(
-- grid=self.grid,
-- visuals_2d=self.visuals_2d,
-- auto_labels=AutoLabels(title="Grid2D", filename="grid"),
-+ """Plot the grid as a 2D scatter."""
-+ is_sub = self.mat_plot_2d.is_for_subplot
-+ ax = self.mat_plot_2d.setup_subplot() if is_sub else None
-+
-+ output_path, filename, fmt = _output_for_mat_plot(
-+ self.mat_plot_2d, is_sub, "grid"
-+ )
-+
-+ grid_plot = self.grid.over_sampled if plot_over_sampled_grid else self.grid
-+
-+ plot_grid(
-+ grid=np.array(grid_plot.array),
-+ ax=ax,
-+ lines=_lines_from_visuals(self.visuals_2d),
- color_array=color_array,
-- plot_grid_lines=plot_grid_lines,
-- plot_over_sampled_grid=plot_over_sampled_grid,
-+ output_path=output_path,
-+ output_filename=filename,
-+ output_format=fmt,
- )
-
-
-@@ -129,29 +205,6 @@ class YX1DPlotter(AbstractPlotter):
- plot_yx_dict=None,
- auto_labels=AutoLabels(),
- ):
-- """
-- Plots two 1D objects using the matplotlib method `plot()` (or a similar method) and many other matplotlib
-- functions which customize the plot's appearance.
--
-- The `mat_plot_1d` attribute wraps matplotlib function calls to make the figure. By default, the settings
-- passed to every matplotlib function called are those specified in the `config/visualize/mat_wrap/*.ini` files,
-- but a user can manually input values into `MatPlot1d` to customize the figure's appearance.
--
-- Overlaid on the figure are visuals, contained in the `Visuals1D` object. Attributes may be extracted from
-- the `Array1D` and plotted via the visuals object.
--
-- Parameters
-- ----------
-- y
-- The 1D y values the plotter plot.
-- x
-- The 1D x values the plotter plot.
-- mat_plot_1d
-- Contains objects which wrap the matplotlib function calls that make 1D plots.
-- visuals_1d
-- Contains 1D visuals that can be overlaid on 1D plots.
-- """
--
- if isinstance(y, list):
- y = Array1D.no_mask(values=y, pixel_scales=1.0)
-
-@@ -169,17 +222,31 @@ class YX1DPlotter(AbstractPlotter):
- self.auto_labels = auto_labels
-
- def figure_1d(self):
-- """
-- Plots the plotter's y and x values in 1D.
-- """
--
-- self.mat_plot_1d.plot_yx(
-- y=self.y,
-- x=self.x,
-- visuals_1d=self.visuals_1d,
-- auto_labels=self.auto_labels,
-- should_plot_grid=self.should_plot_grid,
-- should_plot_zero=self.should_plot_zero,
-- plot_axis_type_override=self.plot_axis_type,
-- **self.plot_yx_dict,
-+ """Plot the y and x values as a 1D line."""
-+ y_arr = self.y.array if hasattr(self.y, "array") else np.array(self.y)
-+ x_arr = self.x.array if hasattr(self.x, "array") else np.array(self.x)
-+
-+ is_sub = self.mat_plot_1d.is_for_subplot
-+ ax = self.mat_plot_1d.setup_subplot() if is_sub else None
-+
-+ output_path, filename, fmt = _output_for_mat_plot(
-+ self.mat_plot_1d, is_sub, self.auto_labels.filename or "yx"
-+ )
-+
-+ shaded = None
-+ if self.visuals_1d is not None and self.visuals_1d.shaded_region is not None:
-+ shaded = self.visuals_1d.shaded_region
-+
-+ plot_yx(
-+ y=y_arr,
-+ x=x_arr,
-+ ax=ax,
-+ shaded_region=shaded,
-+ title=self.auto_labels.title or "",
-+ xlabel=self.auto_labels.xlabel or "",
-+ ylabel=self.auto_labels.ylabel or "",
-+ plot_axis_type=self.plot_axis_type or "linear",
-+ output_path=output_path,
-+ output_filename=filename,
-+ output_format=fmt,
- )
---
-2.43.0
-
diff --git a/patches/autoarray/0003-PR-A3-replace-mat_plot_2d.plot_array-in-FitImagingPl.patch b/patches/autoarray/0003-PR-A3-replace-mat_plot_2d.plot_array-in-FitImagingPl.patch
deleted file mode 100644
index 019e489b81..0000000000
--- a/patches/autoarray/0003-PR-A3-replace-mat_plot_2d.plot_array-in-FitImagingPl.patch
+++ /dev/null
@@ -1,172 +0,0 @@
-From ebbb315cdd0eee0a3cc4e7c2ea0600859cc95330 Mon Sep 17 00:00:00 2001
-From: Claude
-Date: Mon, 16 Mar 2026 17:31:52 +0000
-Subject: [PATCH 3/3] PR A3: replace mat_plot_2d.plot_array in
- FitImagingMeta with plot_array()
-
-Bridge FitImagingMeta.figures_2d() to use the new direct-matplotlib
-plot_array() function via a _plot_array() helper method, eliminating the
-MatWrap system for fit imaging plots.
-
-https://claude.ai/code/session_01CzJBy8KvFXiNchoNdk5i9k
----
- autoarray/fit/plot/fit_imaging_plotters.py | 72 +++++++++++++++++-----
- 1 file changed, 55 insertions(+), 17 deletions(-)
-
-diff --git a/autoarray/fit/plot/fit_imaging_plotters.py b/autoarray/fit/plot/fit_imaging_plotters.py
-index 86aa0d34..20552945 100644
---- a/autoarray/fit/plot/fit_imaging_plotters.py
-+++ b/autoarray/fit/plot/fit_imaging_plotters.py
-@@ -1,10 +1,19 @@
-+import numpy as np
- from typing import Callable
-
- from autoarray.plot.abstract_plotters import AbstractPlotter
- from autoarray.plot.visuals.two_d import Visuals2D
- from autoarray.plot.mat_plot.two_d import MatPlot2D
- from autoarray.plot.auto_labels import AutoLabels
-+from autoarray.plot.plots.array import plot_array
- from autoarray.fit.fit_imaging import FitImaging
-+from autoarray.structures.plot.structure_plotters import (
-+ _mask_edge_from,
-+ _grid_from_visuals,
-+ _lines_from_visuals,
-+ _positions_from_visuals,
-+ _output_for_mat_plot,
-+)
-
-
- class FitImagingMeta(AbstractPlotter):
-@@ -43,6 +52,44 @@ class FitImagingMeta(AbstractPlotter):
- self.fit = fit
- self.residuals_symmetric_cmap = residuals_symmetric_cmap
-
-+ def _plot_array(self, array, auto_labels, visuals_2d=None):
-+ """Helper: plot an Array2D using the new direct-matplotlib function."""
-+ if array is None:
-+ return
-+
-+ v2d = visuals_2d if visuals_2d is not None else self.visuals_2d
-+ is_sub = self.mat_plot_2d.is_for_subplot
-+ ax = self.mat_plot_2d.setup_subplot() if is_sub else None
-+
-+ output_path, filename, fmt = _output_for_mat_plot(
-+ self.mat_plot_2d,
-+ is_sub,
-+ auto_labels.filename if auto_labels else "array",
-+ )
-+
-+ try:
-+ arr = array.native.array
-+ extent = array.geometry.extent
-+ except AttributeError:
-+ arr = np.asarray(array)
-+ extent = None
-+
-+ plot_array(
-+ array=arr,
-+ ax=ax,
-+ extent=extent,
-+ mask=_mask_edge_from(array if hasattr(array, "mask") else None, v2d),
-+ grid=_grid_from_visuals(v2d),
-+ positions=_positions_from_visuals(v2d),
-+ lines=_lines_from_visuals(v2d),
-+ title=auto_labels.title if auto_labels else "",
-+ colormap=self.mat_plot_2d.cmap.cmap,
-+ use_log10=self.mat_plot_2d.use_log10,
-+ output_path=output_path,
-+ output_filename=filename,
-+ output_format=fmt,
-+ )
-+
- def figures_2d(
- self,
- data: bool = False,
-@@ -82,57 +129,50 @@ class FitImagingMeta(AbstractPlotter):
- """
-
- if data:
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.fit.data,
-- visuals_2d=self.visuals_2d,
- auto_labels=AutoLabels(title="Data", filename=f"data{suffix}"),
- )
-
- if noise_map:
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.fit.noise_map,
-- visuals_2d=self.visuals_2d,
- auto_labels=AutoLabels(
- title="Noise-Map", filename=f"noise_map{suffix}"
- ),
- )
-
- if signal_to_noise_map:
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.fit.signal_to_noise_map,
-- visuals_2d=self.visuals_2d,
- auto_labels=AutoLabels(
- title="Signal-To-Noise Map", filename=f"signal_to_noise_map{suffix}"
- ),
- )
-
- if model_image:
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.fit.model_data,
-- visuals_2d=self.visuals_2d,
- auto_labels=AutoLabels(
- title="Model Image", filename=f"model_image{suffix}"
- ),
- )
-
- cmap_original = self.mat_plot_2d.cmap
--
- if self.residuals_symmetric_cmap:
- self.mat_plot_2d.cmap = self.mat_plot_2d.cmap.symmetric_cmap_from()
-
- if residual_map:
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.fit.residual_map,
-- visuals_2d=self.visuals_2d,
- auto_labels=AutoLabels(
- title="Residual Map", filename=f"residual_map{suffix}"
- ),
- )
-
- if normalized_residual_map:
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.fit.normalized_residual_map,
-- visuals_2d=self.visuals_2d,
- auto_labels=AutoLabels(
- title="Normalized Residual Map",
- filename=f"normalized_residual_map{suffix}",
-@@ -142,18 +182,16 @@ class FitImagingMeta(AbstractPlotter):
- self.mat_plot_2d.cmap = cmap_original
-
- if chi_squared_map:
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.fit.chi_squared_map,
-- visuals_2d=self.visuals_2d,
- auto_labels=AutoLabels(
- title="Chi-Squared Map", filename=f"chi_squared_map{suffix}"
- ),
- )
-
- if residual_flux_fraction_map:
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.fit.residual_map,
-- visuals_2d=self.visuals_2d,
- auto_labels=AutoLabels(
- title="Residual Flux Fraction Map",
- filename=f"residual_flux_fraction_map{suffix}",
---
-2.43.0
-
diff --git a/patches/autogalaxy/0001-PR-G1-G2-replace-mat_plot_2d.plot_array-with-_plot_a.patch b/patches/autogalaxy/0001-PR-G1-G2-replace-mat_plot_2d.plot_array-with-_plot_a.patch
deleted file mode 100644
index de7542f3ac..0000000000
--- a/patches/autogalaxy/0001-PR-G1-G2-replace-mat_plot_2d.plot_array-with-_plot_a.patch
+++ /dev/null
@@ -1,466 +0,0 @@
-From 01763ab468688ef6222694f14dbc073755ac268f Mon Sep 17 00:00:00 2001
-From: Claude
-Date: Mon, 16 Mar 2026 17:32:12 +0000
-Subject: [PATCH] PR G1-G2: replace mat_plot_2d.plot_array with _plot_array()
- bridge in all plotters
-
-- Add autogalaxy/plot/plots/overlays.py with helpers to extract critical
- curves, caustics, and profile centres from Visuals2D as plain arrays
-- Add _plot_array() and _plot_grid() bridge methods to the Plotter base class
- that route to the new direct-matplotlib plot_array()/plot_grid() functions
-- Update all autogalaxy plotters to use self._plot_array() instead of
- self.mat_plot_2d.plot_array(), covering: LightProfile, BasisPlotter,
- MassPlotter, Galaxy, Galaxies, AdaptPlotter,
- FitImaging, FitEllipsePlotter, FitEllipsePDFPlotter
-
-https://claude.ai/code/session_01CzJBy8KvFXiNchoNdk5i9k
----
- .../ellipse/plot/fit_ellipse_plotters.py | 4 +-
- autogalaxy/galaxy/plot/adapt_plotters.py | 4 +-
- autogalaxy/galaxy/plot/galaxies_plotters.py | 6 +-
- autogalaxy/galaxy/plot/galaxy_plotters.py | 2 +-
- .../imaging/plot/fit_imaging_plotters.py | 11 +--
- autogalaxy/plot/abstract_plotters.py | 80 +++++++++++++++
- autogalaxy/plot/mass_plotter.py | 15 +--
- autogalaxy/plot/plots/__init__.py | 6 ++
- autogalaxy/plot/plots/overlays.py | 98 +++++++++++++++++++
- autogalaxy/profiles/plot/basis_plotters.py | 2 +-
- .../profiles/plot/light_profile_plotters.py | 2 +-
- 11 files changed, 201 insertions(+), 29 deletions(-)
- create mode 100644 autogalaxy/plot/plots/__init__.py
- create mode 100644 autogalaxy/plot/plots/overlays.py
-
-diff --git a/autogalaxy/ellipse/plot/fit_ellipse_plotters.py b/autogalaxy/ellipse/plot/fit_ellipse_plotters.py
-index 0bb67a21..0506f810 100644
---- a/autogalaxy/ellipse/plot/fit_ellipse_plotters.py
-+++ b/autogalaxy/ellipse/plot/fit_ellipse_plotters.py
-@@ -89,7 +89,7 @@ class FitEllipsePlotter(Plotter):
- positions=ellipse_list, lines=ellipse_list
- )
-
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.fit_list[0].data,
- visuals_2d=visuals_2d,
- auto_labels=aplt.AutoLabels(
-@@ -217,7 +217,7 @@ class FitEllipsePDFPlotter(Plotter):
- lines=median_ellipse, fill_region=[y_fill, x_fill]
- )
-
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.fit_pdf_list[0][0].data,
- visuals_2d=visuals_2d,
- auto_labels=aplt.AutoLabels(
-diff --git a/autogalaxy/galaxy/plot/adapt_plotters.py b/autogalaxy/galaxy/plot/adapt_plotters.py
-index a2b07e2e..d9f7818d 100644
---- a/autogalaxy/galaxy/plot/adapt_plotters.py
-+++ b/autogalaxy/galaxy/plot/adapt_plotters.py
-@@ -27,7 +27,7 @@ class AdaptPlotter(Plotter):
- The adapt model image that is plotted.
- """
-
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=model_image,
- visuals_2d=self.visuals_2d,
- auto_labels=aplt.AutoLabels(
-@@ -44,7 +44,7 @@ class AdaptPlotter(Plotter):
- galaxy_image
- The galaxy image that is plotted.
- """
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=galaxy_image,
- visuals_2d=self.visuals_2d,
- auto_labels=aplt.AutoLabels(
-diff --git a/autogalaxy/galaxy/plot/galaxies_plotters.py b/autogalaxy/galaxy/plot/galaxies_plotters.py
-index e49a8e1a..c3b1ed1b 100644
---- a/autogalaxy/galaxy/plot/galaxies_plotters.py
-+++ b/autogalaxy/galaxy/plot/galaxies_plotters.py
-@@ -146,7 +146,7 @@ class Galaxies(Plotter):
- Add a suffix to the end of the filename the plot is saved to hard-disk using.
- """
- if image:
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.galaxies.image_2d_from(grid=self.grid),
- visuals_2d=self.visuals_2d,
- auto_labels=aplt.AutoLabels(
-@@ -160,7 +160,7 @@ class Galaxies(Plotter):
- else:
- title = f"Plane Image{title_suffix}"
-
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.galaxies.plane_image_2d_from(
- grid=self.grid, zoom_to_brightest=zoom_to_brightest
- ),
-@@ -177,7 +177,7 @@ class Galaxies(Plotter):
- else:
- title = f"Plane Grid{title_suffix}"
-
-- self.mat_plot_2d.plot_grid(
-+ self._plot_grid(
- grid=self.grid,
- visuals_2d=self.visuals_2d,
- auto_labels=aplt.AutoLabels(
-diff --git a/autogalaxy/galaxy/plot/galaxy_plotters.py b/autogalaxy/galaxy/plot/galaxy_plotters.py
-index d1a37283..d2464f81 100644
---- a/autogalaxy/galaxy/plot/galaxy_plotters.py
-+++ b/autogalaxy/galaxy/plot/galaxy_plotters.py
-@@ -201,7 +201,7 @@ class Galaxy(Plotter):
- Whether to make a 2D plot (via `imshow`) of the magnification.
- """
- if image:
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.galaxy.image_2d_from(grid=self.grid),
- visuals_2d=self.visuals_2d,
- auto_labels=aplt.AutoLabels(
-diff --git a/autogalaxy/imaging/plot/fit_imaging_plotters.py b/autogalaxy/imaging/plot/fit_imaging_plotters.py
-index 3f21b5a2..8a68222a 100644
---- a/autogalaxy/imaging/plot/fit_imaging_plotters.py
-+++ b/autogalaxy/imaging/plot/fit_imaging_plotters.py
-@@ -131,14 +131,7 @@ class FitImaging(Plotter):
-
- for galaxy_index in galaxy_indices:
- if subtracted_image:
-- self.mat_plot_2d.cmap.kwargs["vmin"] = np.max(
-- self.fit.model_images_of_galaxies_list[galaxy_index]
-- )
-- self.mat_plot_2d.cmap.kwargs["vmin"] = np.min(
-- self.fit.model_images_of_galaxies_list[galaxy_index]
-- )
--
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.fit.subtracted_images_of_galaxies_list[galaxy_index],
- visuals_2d=self.visuals_2d,
- auto_labels=aplt.AutoLabels(
-@@ -148,7 +141,7 @@ class FitImaging(Plotter):
- )
-
- if model_image:
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.fit.model_images_of_galaxies_list[galaxy_index],
- visuals_2d=self.visuals_2d,
- auto_labels=aplt.AutoLabels(
-diff --git a/autogalaxy/plot/abstract_plotters.py b/autogalaxy/plot/abstract_plotters.py
-index 3acd3667..79bf31f2 100644
---- a/autogalaxy/plot/abstract_plotters.py
-+++ b/autogalaxy/plot/abstract_plotters.py
-@@ -2,7 +2,19 @@ from autoarray.plot.wrap.base.abstract import set_backend
-
- set_backend()
-
-+import numpy as np
-+
- from autoarray.plot.abstract_plotters import AbstractPlotter
-+from autoarray.plot.plots.array import plot_array
-+from autoarray.structures.plot.structure_plotters import (
-+ _mask_edge_from,
-+ _grid_from_visuals,
-+ _output_for_mat_plot,
-+)
-+from autogalaxy.plot.plots.overlays import (
-+ _galaxy_lines_from_visuals,
-+ _galaxy_positions_from_visuals,
-+)
-
- from autogalaxy.plot.mat_plot.one_d import MatPlot1D
- from autogalaxy.plot.mat_plot.two_d import MatPlot2D
-@@ -32,3 +44,71 @@ class Plotter(AbstractPlotter):
-
- self.visuals_2d = visuals_2d or Visuals2D()
- self.mat_plot_2d = mat_plot_2d or MatPlot2D()
-+
-+ def _plot_array(self, array, visuals_2d, auto_labels):
-+ """Bridge: replace mat_plot_2d.plot_array() with the new plot_array() function."""
-+ if array is None:
-+ return
-+
-+ is_sub = self.mat_plot_2d.is_for_subplot
-+ ax = self.mat_plot_2d.setup_subplot() if is_sub else None
-+
-+ output_path, filename, fmt = _output_for_mat_plot(
-+ self.mat_plot_2d,
-+ is_sub,
-+ auto_labels.filename if auto_labels else "array",
-+ )
-+
-+ try:
-+ arr = array.native.array
-+ extent = array.geometry.extent
-+ except AttributeError:
-+ arr = np.asarray(array)
-+ extent = None
-+
-+ v2d = visuals_2d if visuals_2d is not None else self.visuals_2d
-+
-+ plot_array(
-+ array=arr,
-+ ax=ax,
-+ extent=extent,
-+ mask=_mask_edge_from(array if hasattr(array, "mask") else None, v2d),
-+ grid=_grid_from_visuals(v2d),
-+ positions=_galaxy_positions_from_visuals(v2d),
-+ lines=_galaxy_lines_from_visuals(v2d),
-+ title=auto_labels.title if auto_labels else "",
-+ colormap=self.mat_plot_2d.cmap.cmap,
-+ use_log10=self.mat_plot_2d.use_log10,
-+ output_path=output_path,
-+ output_filename=filename,
-+ output_format=fmt,
-+ )
-+
-+ def _plot_grid(self, grid, visuals_2d, auto_labels):
-+ """Bridge: replace mat_plot_2d.plot_grid() with plot_grid() function."""
-+ from autoarray.plot.plots.grid import plot_grid
-+
-+ is_sub = self.mat_plot_2d.is_for_subplot
-+ ax = self.mat_plot_2d.setup_subplot() if is_sub else None
-+
-+ output_path, filename, fmt = _output_for_mat_plot(
-+ self.mat_plot_2d,
-+ is_sub,
-+ auto_labels.filename if auto_labels else "grid",
-+ )
-+
-+ v2d = visuals_2d if visuals_2d is not None else self.visuals_2d
-+
-+ try:
-+ grid_arr = np.array(grid.array if hasattr(grid, "array") else grid)
-+ except Exception:
-+ grid_arr = np.asarray(grid)
-+
-+ plot_grid(
-+ grid=grid_arr,
-+ ax=ax,
-+ lines=_galaxy_lines_from_visuals(v2d),
-+ output_path=output_path,
-+ output_filename=filename,
-+ output_format=fmt,
-+ )
-diff --git a/autogalaxy/plot/mass_plotter.py b/autogalaxy/plot/mass_plotter.py
-index 16167ad5..fcd7d483 100644
---- a/autogalaxy/plot/mass_plotter.py
-+++ b/autogalaxy/plot/mass_plotter.py
-@@ -64,24 +64,22 @@ class MassPlotter(Plotter):
- """
-
- if convergence:
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.mass_obj.convergence_2d_from(grid=self.grid),
- visuals_2d=self.visuals_2d_with_critical_curves,
- auto_labels=aplt.AutoLabels(
- title=f"Convergence{title_suffix}",
- filename=f"convergence_2d{filename_suffix}",
-- cb_unit="",
- ),
- )
-
- if potential:
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.mass_obj.potential_2d_from(grid=self.grid),
- visuals_2d=self.visuals_2d_with_critical_curves,
- auto_labels=aplt.AutoLabels(
- title=f"Potential{title_suffix}",
- filename=f"potential_2d{filename_suffix}",
-- cb_unit="",
- ),
- )
-
-@@ -91,13 +89,12 @@ class MassPlotter(Plotter):
- values=deflections.slim[:, 0], mask=self.grid.mask
- )
-
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=deflections_y,
- visuals_2d=self.visuals_2d_with_critical_curves,
- auto_labels=aplt.AutoLabels(
- title=f"Deflections Y{title_suffix}",
- filename=f"deflections_y_2d{filename_suffix}",
-- cb_unit="",
- ),
- )
-
-@@ -107,20 +104,19 @@ class MassPlotter(Plotter):
- values=deflections.slim[:, 1], mask=self.grid.mask
- )
-
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=deflections_x,
- visuals_2d=self.visuals_2d_with_critical_curves,
- auto_labels=aplt.AutoLabels(
- title=f"Deflections X{title_suffix}",
- filename=f"deflections_x_2d{filename_suffix}",
-- cb_unit="",
- ),
- )
-
- if magnification:
- from autogalaxy.operate.lens_calc import LensCalc
-
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=LensCalc.from_mass_obj(
- self.mass_obj
- ).magnification_2d_from(grid=self.grid),
-@@ -128,6 +124,5 @@ class MassPlotter(Plotter):
- auto_labels=aplt.AutoLabels(
- title=f"Magnification{title_suffix}",
- filename=f"magnification_2d{filename_suffix}",
-- cb_unit="",
- ),
- )
-diff --git a/autogalaxy/plot/plots/__init__.py b/autogalaxy/plot/plots/__init__.py
-new file mode 100644
-index 00000000..1f20cbdc
---- /dev/null
-+++ b/autogalaxy/plot/plots/__init__.py
-@@ -0,0 +1,6 @@
-+from autogalaxy.plot.plots.overlays import (
-+ _critical_curves_from_visuals,
-+ _caustics_from_visuals,
-+ _galaxy_lines_from_visuals,
-+ _galaxy_positions_from_visuals,
-+)
-diff --git a/autogalaxy/plot/plots/overlays.py b/autogalaxy/plot/plots/overlays.py
-new file mode 100644
-index 00000000..9f79ad94
---- /dev/null
-+++ b/autogalaxy/plot/plots/overlays.py
-@@ -0,0 +1,98 @@
-+"""
-+Helper functions to extract autogalaxy-specific overlay data from Visuals2D
-+objects and convert them to plain numpy arrays suitable for plot_array().
-+"""
-+from typing import List, Optional
-+
-+import numpy as np
-+
-+
-+def _critical_curves_from_visuals(visuals_2d) -> Optional[List[np.ndarray]]:
-+ """Return list of (N,2) arrays for tangential and radial critical curves."""
-+ if visuals_2d is None:
-+ return None
-+ curves = []
-+ for attr in ("tangential_critical_curves", "radial_critical_curves"):
-+ val = getattr(visuals_2d, attr, None)
-+ if val is None:
-+ continue
-+ try:
-+ for item in val:
-+ try:
-+ arr = np.array(item.array if hasattr(item, "array") else item)
-+ if arr.ndim == 2 and arr.shape[1] == 2 and len(arr) > 0:
-+ curves.append(arr)
-+ except Exception:
-+ pass
-+ except TypeError:
-+ try:
-+ arr = np.array(val.array if hasattr(val, "array") else val)
-+ if arr.ndim == 2 and arr.shape[1] == 2 and len(arr) > 0:
-+ curves.append(arr)
-+ except Exception:
-+ pass
-+ return curves or None
-+
-+
-+def _caustics_from_visuals(visuals_2d) -> Optional[List[np.ndarray]]:
-+ """Return list of (N,2) arrays for tangential and radial caustics."""
-+ if visuals_2d is None:
-+ return None
-+ curves = []
-+ for attr in ("tangential_caustics", "radial_caustics"):
-+ val = getattr(visuals_2d, attr, None)
-+ if val is None:
-+ continue
-+ try:
-+ for item in val:
-+ try:
-+ arr = np.array(item.array if hasattr(item, "array") else item)
-+ if arr.ndim == 2 and arr.shape[1] == 2 and len(arr) > 0:
-+ curves.append(arr)
-+ except Exception:
-+ pass
-+ except TypeError:
-+ try:
-+ arr = np.array(val.array if hasattr(val, "array") else val)
-+ if arr.ndim == 2 and arr.shape[1] == 2 and len(arr) > 0:
-+ curves.append(arr)
-+ except Exception:
-+ pass
-+ return curves or None
-+
-+
-+def _galaxy_lines_from_visuals(visuals_2d) -> Optional[List[np.ndarray]]:
-+ """
-+ Return all line overlays from an autogalaxy Visuals2D, combining regular
-+ lines, critical curves, and caustics into a single list.
-+ """
-+ from autoarray.structures.plot.structure_plotters import _lines_from_visuals
-+
-+ lines = _lines_from_visuals(visuals_2d) or []
-+ critical = _critical_curves_from_visuals(visuals_2d) or []
-+ caustics = _caustics_from_visuals(visuals_2d) or []
-+ combined = lines + critical + caustics
-+ return combined or None
-+
-+
-+def _galaxy_positions_from_visuals(visuals_2d) -> Optional[List[np.ndarray]]:
-+ """
-+ Return all scatter-point overlays from an autogalaxy Visuals2D, combining
-+ regular positions, light/mass profile centres, and multiple images.
-+ """
-+ from autoarray.structures.plot.structure_plotters import _positions_from_visuals
-+
-+ result = _positions_from_visuals(visuals_2d) or []
-+
-+ for attr in ("light_profile_centres", "mass_profile_centres", "multiple_images"):
-+ val = getattr(visuals_2d, attr, None)
-+ if val is None:
-+ continue
-+ try:
-+ arr = np.array(val.array if hasattr(val, "array") else val)
-+ if arr.ndim == 2 and arr.shape[1] == 2 and len(arr) > 0:
-+ result.append(arr)
-+ except Exception:
-+ pass
-+
-+ return result or None
-diff --git a/autogalaxy/profiles/plot/basis_plotters.py b/autogalaxy/profiles/plot/basis_plotters.py
-index 93d4bbc6..3ff5fac1 100644
---- a/autogalaxy/profiles/plot/basis_plotters.py
-+++ b/autogalaxy/profiles/plot/basis_plotters.py
-@@ -115,7 +115,7 @@ class BasisPlotter(Plotter):
- self.open_subplot_figure(number_subplots=len(self.basis.light_profile_list))
-
- for light_profile in self.basis.light_profile_list:
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=light_profile.image_2d_from(grid=self.grid),
- visuals_2d=self.visuals_2d,
- auto_labels=aplt.AutoLabels(title=light_profile.coefficient_tag),
-diff --git a/autogalaxy/profiles/plot/light_profile_plotters.py b/autogalaxy/profiles/plot/light_profile_plotters.py
-index 7292f5eb..07b21f29 100644
---- a/autogalaxy/profiles/plot/light_profile_plotters.py
-+++ b/autogalaxy/profiles/plot/light_profile_plotters.py
-@@ -89,7 +89,7 @@ class LightProfile(Plotter):
- Whether to make a 2D plot (via `imshow`) of the image.
- """
- if image:
-- self.mat_plot_2d.plot_array(
-+ self._plot_array(
- array=self.light_profile.image_2d_from(grid=self.grid),
- visuals_2d=self.visuals_2d,
- auto_labels=aplt.AutoLabels(title="Image", filename="image_2d"),
---
-2.43.0
-