Plotting#

PyAutoGalaxy custom visualization library.

Step-by-step Juypter notebook guides illustrating all objects listed on this page are provided on the autogalaxy_workspace: plot tutorials and it is strongly recommended you use those to learn plot customization.

Examples / Tutorials:

Plotters [aplt]#

Create figures and subplots showing quantities of standard PyAutoGalaxy objects.

Basic Plot Functions:

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.

Galaxy and Light / Mass Profile Subplots:

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.

Imaging Fit Subplots:

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

Create a six-panel subplot summarising a FitImaging.

subplot_fit_imaging_of_galaxy(fit, galaxy_index)

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

Interferometer Fit Subplots:

subplot_fit_interferometer(fit[, ...])

Create a three-panel subplot summarising a FitInterferometer.

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:

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.

Non-linear Search Plot Functions [aplt]#

Module-level functions for visualizing non-linear search results.

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

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

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

log_likelihood_vs_iteration(samples[, ...])

Plot Customization [aplt]#

The plotting API is functional: customization is done by passing keyword arguments directly to any aplt plotting function. There is no MatPlot2D object anymore (nor the old Cmap / Visuals / Units / matplotlib-wrapper classes) — these were removed in favour of the keyword-argument interface below.

Every figure and subplot function accepts:

  • title — the figure title.

  • colormap — the matplotlib colormap name (e.g. "jet", "hot", "gray").

  • use_log10 — if True, plot the colormap on a log10 scale.

  • output_path — directory to save the figure to (omit to display it interactively).

  • output_filename — the saved file’s name.

  • output_format — the saved file’s format, e.g. "png" or "pdf".

For example:

import autogalaxy.plot as aplt

# Customize the appearance:
aplt.plot_array(array=image, title="Image", colormap="jet", use_log10=True)

# Save to disk instead of displaying:
aplt.plot_array(
    array=image, output_path="output", output_filename="image", output_format="png"
)

Default plotting values (figure size, fonts, colormaps, ticks, labels, …) are set via the workspace config/visualize YAML files rather than in code, so most figures need no customization at all.

Figure Output [aplt]#

The Output object gives lower-level control of how and where figures are written to disk, and is accepted by the plotting functions in place of the individual output_* keyword arguments.

Output

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