Plotting#

PyAutoLens custom visualization library.

Step-by-step Juypter notebook guides illustrating all objects listed on this page are provided on the autolens_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 PyAutoLens 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.

Tracer and Galaxies Subplots:

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:

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_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 Fit Subplots:

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.

Point Source Subplots:

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

Produce a subplot summarising a FitPointDataset.

subplot_point_dataset(dataset[, ...])

Produce a subplot visualising a PointDataset.

Subhalo Detection Subplots:

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:

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.

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 autolens.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.