Plotting#

Use autolens.plot to inspect datasets, models and fits. Functions produce individual figures or diagnostic subplots; pass plotting options directly to the function you call.

For a runnable introduction and customization examples, open the plotting guide.

Plot an image#

Given an existing Array2D called image:

import autolens.plot as aplt

aplt.plot_array(array=image, title="Image", colormap="gray")

Choose a plot#

Choose the group that matches the object or result you want to inspect. The linked references give each function’s arguments.

Basic plots#

Display an array or a grid of coordinates, or write an array to a .fits file.

plot_array(array[, title, output_path, ...])

Plot an autoarray Array2D to file or onto an existing Axes.

plot_grid(grid[, title, output_path, ...])

Plot an autoarray Grid2D as a scatter plot.

fits_array(array, file_path[, overwrite, ...])

Write an autoarray Array2D, Mask2D, or array-like to a .fits file.

Dataset Subplots#

Inspect an imaging or interferometer dataset before fitting it, or write its components to .fits files.

subplot_imaging_dataset(dataset[, ...])

3×3 subplot of core Imaging dataset components.

subplot_imaging_dataset_intro(dataset[, ...])

Four-panel introduction: Image, Noise map, Signal-to-noise map and PSF.

subplot_imaging_dataset_list(dataset_list[, ...])

n×3 subplot showing core components for each dataset in a list.

fits_imaging(dataset[, file_path, ...])

Write an Imaging dataset to FITS.

subplot_interferometer_dirty_images(dataset)

1x3 subplot of dirty image, dirty noise map, and dirty S/N map.

fits_interferometer(dataset[, file_path, ...])

Write an Interferometer dataset to FITS.

Tracer and Galaxies subplots#

Inspect the lens model, its lensed images and the contributions from its galaxies.

subplot_tracer(tracer, grid[, output_path, ...])

Multi-panel subplot of the tracer: image, source images, and mass quantities.

subplot_lensed_images(tracer, grid[, ...])

Produce a subplot with one panel per tracer plane showing each plane's image.

subplot_galaxies_images(tracer, grid[, ...])

Produce a subplot showing per-galaxy images for every plane in the tracer.

Imaging Fit subplots#

Compare the image data and fitted model, and inspect residuals and other fit diagnostics.

subplot_fit_imaging(fit[, output_path, ...])

Produce a 12-panel subplot summarising an imaging fit.

subplot_fit_imaging_log10(fit[, ...])

Produce a 12-panel subplot summarising an imaging fit with log10 colour scaling.

subplot_fit_imaging_x1_plane(fit[, ...])

Produce a 6-panel subplot for a single-plane tracer imaging fit.

subplot_fit_imaging_log10_x1_plane(fit[, ...])

Produce a 6-panel log10 subplot for a single-plane tracer imaging fit.

subplot_fit_imaging_of_planes(fit[, ...])

Produce a 4-panel subplot for each plane in the tracer.

subplot_fit_imaging_tracer(fit[, ...])

Produce a 9-panel tracer subplot derived from a FitImaging object.

subplot_fit_imaging_mappings(fit[, ...])

2x2 subplot showing, in one look, how the brightest regions of the source map to the image plane and back.

subplot_fit_combined(fit_list[, ...])

Produce a combined multi-row subplot for a list of FitImaging objects.

subplot_fit_combined_log10(fit_list[, ...])

Produce a combined log10 multi-row subplot for a list of FitImaging objects.

Interferometer subplots#

Inspect visibilities, fits and reconstructed images. Dirty images are useful diagnostics; the interferometer fit is evaluated in visibility space.

subplot_interferometer_dataset(dataset[, ...])

2x3 subplot of interferometer dataset components.

subplot_fit_interferometer(fit[, ...])

Produce a 12-panel subplot summarising an interferometer fit.

subplot_fit_interferometer_real_space(fit[, ...])

Produce a real-space subplot for an interferometer fit.

subplot_fit_interferometer_dirty_images(fit)

Produce a 2×3 subplot of dirty-image diagnostics for an interferometer fit.

subplot_fit_interferometer_tracer(fit[, ...])

Produce a 9-panel tracer subplot derived from a FitInterferometer object.

subplot_fit_interferometer_combined(fit_list)

Produce a combined multi-row subplot for a list of FitInterferometer objects.

Point Source subplots#

Inspect the observed point-source positions, fitted predictions and solver output.

subplot_fit_point(fit[, output_path, ...])

Produce fit.png of a FitPointDataset: the "Fit Positions" panel of plot_fit_positions for this one source, plus a "Fit Fluxes" panel when the dataset has fluxes.

subplot_point_dataset(dataset[, ...])

Produce a subplot visualising a PointDataset.

plot_point_solver(solver, tracer, ...[, ...])

Plot how the PointSolver refines its triangle tiling to find the multiple images of a point source.

plot_image_with_points(image, dataset[, ...])

Plot an observed image of a lensed point source (e.g. a quasar) with its point-source positions overlaid.

Subhalo Detection subplots#

Compare subhalo-search results and their associated fits.

subplot_detection_imaging(result, ...[, ...])

Produce a 4-panel subplot summarising subhalo detection from imaging data.

subplot_detection_fits(...[, output_path, ...])

Produce a 6-panel subplot comparing imaging fits with and without a subhalo.

Sensitivity Mapping subplots#

Inspect sensitivity results and their figures of merit across the lens.

subplot_sensitivity_tracer_images(mask, ...)

Produce a 6-panel subplot comparing a perturbed and unperturbed tracer.

subplot_sensitivity(result, data_subtracted)

Produce an 8-panel sensitivity-mapping summary subplot.

subplot_sensitivity_figures_of_merit(result)

Produce a single-panel subplot showing the sensitivity figures-of-merit grid.

Galaxy and Light and Mass Profile subplots#

Inspect profile components, combined galaxy images, basis profiles and adapt images. These functions are implemented by PyAutoGalaxy and re-exported through aplt.

subplot_galaxy_light_profiles(galaxy, grid)

Create a subplot showing the image of every light profile in a galaxy.

subplot_galaxy_mass_profiles(galaxy, grid[, ...])

Create subplots showing lensing quantities for every mass profile in a galaxy.

subplot_basis_image(basis, grid[, ...])

Create a subplot showing the image of every light profile in a basis.

subplot_galaxies(galaxies, grid[, ...])

Create a standard five-panel summary subplot for a collection of galaxies.

subplot_galaxy_images(galaxies, grid[, ...])

Create a subplot showing the individual image of each galaxy.

subplot_adapt_images(...[, output_path, ...])

Create a subplot showing the adapt (model) image for each galaxy.

Galaxy Fit subplots#

Inspect a fit one galaxy at a time, or the real-space and dirty-image views of an interferometer fit. These are the PyAutoGalaxy fit subplots, re-exported through aplt.

subplot_fit_imaging_of_galaxy(fit, galaxy_index)

Create a three-panel subplot focused on a single galaxy contribution.

subplot_fit_dirty_images(fit[, output_path, ...])

Create a six-panel subplot of dirty-image diagnostics for an interferometer fit.

subplot_fit_real_space(fit[, output_path, ...])

Create a real-space summary subplot for an interferometer fit.

Ellipse Fit subplots#

Inspect fitted isophotes and the errors associated with the ellipse fits.

subplot_fit_ellipse(fit_list[, output_path, ...])

Create a two-panel subplot summarising a list of ellipse fits.

subplot_ellipse_errors(fit_pdf_list[, ...])

Create a subplot showing the median ellipse and its uncertainty region from a PDF sample.

Magnification maps#

Map the lensing magnification in the image plane and source plane, and its uncertainty over a set of posterior draws.

plot_magnification_2d(mass_obj, grid[, ...])

Plot the image-plane magnification map of a mass object, with constant-magnification contours.

plot_magnification_source_plane(mapper[, ...])

Plot the magnification of every pixel of a source reconstruction's mesh.

plot_magnification_source_plane_grid(...[, ...])

Plot the source-plane magnification on square pixels, for sources without a mesh.

plot_magnification_uncertainty_2d(...[, ...])

Plot the fractional error of the magnification at every image-plane pixel, over a set of posterior draws.

magnification_fractional_error_2d_from(...)

Return the fractional error of the magnification at every pixel, over a set of posterior draws.

Cluster plots#

Inspect a cluster dataset, its multiple-image positions and the critical curves and caustics of the lens model.

subplot_cluster_dataset(positions_list[, ...])

Combined cluster mosaic: positions overlay | per-plane critical curves (+ image).

plot_positions_overlay(positions_list[, ...])

Plot every source's observed multiple-image positions, per-source coloured, on the full cluster field.

plot_image_group_zooms(positions_list, image)

A panel grid with one zoom per multiple image, rows grouped by source.

plot_critical_curves(tracer, grid[, image, ...])

Plot the critical curves of every source plane of a multi-plane tracer.

plot_caustics(tracer, grid[, plane_indices, ...])

Plot the caustics of every source plane of a multi-plane tracer, in source-plane arcsec coordinates.

Weak Lensing plots#

Inspect a weak-lensing shear dataset, its fit, the shear profile and the convergence map.

subplot_weak_dataset(dataset[, output_path, ...])

Produce a 2x2 subplot mosaic visualising a WeakDataset.

plot_shear_yx_2d(shear_yx[, ax, title, ...])

Plot a shear field as a quiver of headless line segments at galaxy positions.

plot_ellipticities(shear_yx[, ax, title, ...])

Plot a colour-coded scatter of the shear magnitude |gamma| at each galaxy.

plot_phis(shear_yx[, ax, title, ...])

Plot a colour-coded scatter of the shear position angle phi at each galaxy.

plot_noise_map(dataset[, ax, title, ...])

Plot a colour-coded scatter of the per-galaxy shear noise at each position.

subplot_fit_weak(fit[, output_path, ...])

Produce a 2x2 subplot mosaic visualising a FitWeak.

plot_data_vs_model(fit[, ax, title, ...])

Overlay the data and model shear fields as headless quivers on a single axes.

plot_residuals(fit[, ax, title, ...])

Quiver of the per-galaxy residual shear data - model, colour-coded by |residual|.

plot_chi_squared_map(fit[, ax, title, ...])

Colour-coded scatter of per-galaxy chi-squared (sum over the two shear components).

plot_shear_profile(obj[, centre, bins, ax, ...])

Plot binned tangential and cross shear profiles of a WeakDataset or FitWeak.

plot_convergence_map(shear_yx[, ...])

Plot the Kaiser-Squires E-mode convergence reconstruction of a shear field.

Twin comparisons#

Compare a fitted lens (the parent) with a simulated twin made from it (al.twins.compare): images, residuals, convergence, enclosed mass and critical curves.

subplot_twin_comparison(comparison[, ...])

A 2x3 subplot of a TwinComparison (al.twins.compare(parent, twin)).

Search results#

These functions visualize samples and search progress. They are implemented by PyAutoFit and re-exported through aplt.

corner_cornerpy(samples[, path, filename, ...])

corner_anesthetic(samples[, path, filename, ...])

Corner plot of the posterior via anesthetic, over every parameter of the model or, with parameter_indices, over a subset of them (the parameters of one model component, say) so that a many-parameter fit stays readable.

subplot_parameters(samples[, use_log_y, ...])

log_likelihood_vs_iteration(samples[, ...])

output_figure([path, filename, format])

Customize a plot#

Options depend on the function. For plot_array, you can set:

  • title: the figure title.

  • colormap: a Matplotlib colormap, such as "gray" or "viridis".

  • use_log10: request logarithmic colour scaling. Use a linear or suitable signed scale when inspecting quantities that can be negative, such as residuals.

  • output_path, output_filename and output_format: the output directory, filename and format.

Subplot functions may use different options. For example, subplot_tracer accepts title_prefix rather than title and does not expose output_filename. Check the linked signature before transferring options between functions.

Defaults such as figure size, fonts and colours are configured through the workspace’s config/visualize YAML files. See Configuration for the configuration workflow.

Save figures#

For plot_array, save the existing image to output/image.png with:

aplt.plot_array(
    array=image,
    output_path="output",
    output_filename="image",
    output_format="png",
)

The functions above use the output keywords documented in their signatures. Output is a lower-level PyAutoArray helper; it is not a replacement argument for these public plotting functions. Its reference remains available for code that uses it directly.

Output

Sets how the figure or subplot is output, either by displaying it on the screen or writing it to hard-disk.