From 22f849c9cb74d9f88365c60c78da012369396785 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Thu, 29 Oct 2026 12:45:23 +0000 Subject: [PATCH] feat: expose introductory imaging plots and asinh stretch --- autogalaxy/plot/__init__.py | 1 + autogalaxy/util/plot_utils.py | 5 +++++ test_autogalaxy/plot/test_intro_plot.py | 15 +++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 test_autogalaxy/plot/test_intro_plot.py diff --git a/autogalaxy/plot/__init__.py b/autogalaxy/plot/__init__.py index 4b321fd4c..dc5e1a00a 100644 --- a/autogalaxy/plot/__init__.py +++ b/autogalaxy/plot/__init__.py @@ -10,6 +10,7 @@ from autoarray.dataset.plot.imaging_plots import ( subplot_imaging_dataset, + subplot_imaging_dataset_intro, subplot_imaging_dataset_list, fits_imaging, ) diff --git a/autogalaxy/util/plot_utils.py b/autogalaxy/util/plot_utils.py index e0e5c7c95..0ab06dd1c 100644 --- a/autogalaxy/util/plot_utils.py +++ b/autogalaxy/util/plot_utils.py @@ -199,6 +199,7 @@ def plot_array( cb_unit=None, ax=None, arcsec_after_decimal=None, + stretch=None, ): """Plot an autoarray ``Array2D`` to file or onto an existing ``Axes``. @@ -223,6 +224,9 @@ def plot_array( colormap : str Matplotlib colormap name, or ``"default"`` to use the autoarray default (``"jet"``). + stretch : float or None + Positive asinh linear-width fraction of the colour range. Smaller + values reveal fainter structure. Incompatible with ``use_log10=True``. use_log10 : bool If ``True`` apply a log₁₀ stretch to the array values. vmin, vmax : float or None @@ -287,6 +291,7 @@ def plot_array( use_log10=use_log10, vmin=vmin, vmax=vmax, + stretch=stretch, cb_unit=cb_unit, arcsec_after_decimal=arcsec_after_decimal, output_path=_output_path, diff --git a/test_autogalaxy/plot/test_intro_plot.py b/test_autogalaxy/plot/test_intro_plot.py new file mode 100644 index 000000000..111dc4110 --- /dev/null +++ b/test_autogalaxy/plot/test_intro_plot.py @@ -0,0 +1,15 @@ +"""The public Galaxy plotting API forwards stretch and exposes the compositor.""" +import numpy as np +import matplotlib.pyplot as plt +from matplotlib.colors import AsinhNorm +import autogalaxy.plot as aplt +import autoarray as aa +from autoarray.dataset.plot.imaging_plots import subplot_imaging_dataset_intro + + +def test_intro_export_and_stretch_forwarding(): + assert aplt.subplot_imaging_dataset_intro is subplot_imaging_dataset_intro + fig, ax = plt.subplots() + aplt.plot_array(aa.Array2D.no_mask(np.eye(3), pixel_scales=.1), ax=ax, stretch=.01) + assert isinstance(ax.images[0].norm, AsinhNorm) + plt.close(fig)