autolens.plot.GridScatter

class autolens.plot.GridScatter(**kwargs)

Scatters an input set of grid points, for example (y,x) coordinates or data structures representing 2D (y,x) coordinates like a Grid2D or Grid2DIrregular. List of (y,x) coordinates are plotted with varying colors.

This object wraps the following Matplotlib methods:

There are a number of children of this method in the mat_obj.py module that plot specific sets of (y,x) points. Each of these objects uses uses their own config file and settings so that each has a unique appearance on every figure:

  • OriginScatter: plots the (y,x) coordinates of the origin of a data structure (e.g. as a black cross).
  • MaskScatter: plots a mask over an image, using the Mask2d object’s (y,x) edge_grid_sub_1 property.
  • BorderScatter: plots a border over an image, using the `Mask2d object’s (y,x) border_grid_sub_1 property.
  • PositionsScatter: plots the (y,x) coordinates that are input in a plotter via the positions input.
  • IndexScatter: plots specific (y,x) coordinates of a grid (or grids) via their 1d or 2d indexes.
  • PixelizationGridScatter: plots the grid of a Pixelization object (see autoarray.inversion).
Parameters:colors ([str]) – The color or list of colors that the grid is plotted using. For plotting indexes or a grid list, a list of colors can be specified which the plot cycles through.
__init__(**kwargs)

An abstract base class for wrapping matplotlib plotting methods.

Classes are used to wrap matplotlib so that the data structures in the autoarray.structures package can be plotted in standardized withs. This exploits how these structures have specific formats, units, properties etc. This allows us to make a simple API for plotting structures, for example to plot an Array2D structure:

import autoarray as aa import autoarray.plot as aplt

arr = aa.Array2D.manual_native(array=[[1.0, 1.0], [2.0, 2.0]], pixel_scales=2.0) aplt.Array2D(array=arr)

The wrapped Mat objects make it simple to customize how matplotlib visualizes this data structure, for example we can customize the figure size and colormap using the Figure and Cmap objects.

figure = aplt.Figure(figsize=(7,7), aspect=”square”) cmap = aplt.Cmap(cmap=”jet”, vmin=1.0, vmax=2.0)

plotter = aplt.MatPlot2D(figure=figure, cmap=cmap)

aplt.Array2D(array=arr, plotter=plotter)

The Plotter object is detailed in the autoarray.plot.plotter package.

The matplotlib wrapper objects in ths module also use configuration files to choose their default settings. For example, in autoarray.config.visualize.mat_base.Figure.ini you will note the section:

[figure] figsize=(7, 7)

[subplot] figsize=auto

This specifies that when a data structure (like the Array2D above) is plotted, the figsize will always be (7,7) when a single figure is plotted and it will be chosen automatically if a subplot is plotted. This allows one to customize the matplotlib settings of every plot in a project.

Methods

__init__(**kwargs) An abstract base class for wrapping matplotlib plotting methods.
scatter_grid(grid, …) Plot an input grid of (y,x) coordinates using the matplotlib method plt.scatter.
scatter_grid_colored(grid, …) Plot an input grid of (y,x) coordinates using the matplotlib method plt.scatter.
scatter_grid_indexes(grid, …) Plot specific points of an input grid of (y,x) coordinates, which are specified according to the 1D or 2D indexes of the Grid2D.
scatter_grid_list(grid_list, …) Plot an input list of grids of (y,x) coordinates using the matplotlib method plt.scatter.

Attributes

config_dict
config_folder
scatter_grid(grid: Union[numpy.ndarray, autoarray.structures.grids.two_d.grid_2d.Grid2D])

Plot an input grid of (y,x) coordinates using the matplotlib method plt.scatter.

Parameters:
  • grid (Grid2D) – The grid of (y,x) coordinates that is plotted.
  • errors – The error on every point of the grid that is plotted.
scatter_grid_list(grid_list: Union[List[autoarray.structures.grids.two_d.grid_2d.Grid2D], List[autoarray.structures.grids.two_d.grid_2d_irregular.Grid2DIrregular]])

Plot an input list of grids of (y,x) coordinates using the matplotlib method plt.scatter.

This method colors each grid in each entry of the list the same, so that the different grids are visible in the plot.

Parameters:grid_list – The list of grids of (y,x) coordinates that are plotted.
scatter_grid_colored(grid: Union[numpy.ndarray, autoarray.structures.grids.two_d.grid_2d.Grid2D], color_array: numpy.ndarray, cmap: str)

Plot an input grid of (y,x) coordinates using the matplotlib method plt.scatter.

The method colors the scattered grid according to an input ndarray of color values, using an input colormap.

Parameters:
  • grid (Grid2D) – The grid of (y,x) coordinates that is plotted.
  • color_array (ndarray) – The array of RGB color values used to color the grid.
  • cmap (str) – The Matplotlib colormap used for the grid point coloring.
scatter_grid_indexes(grid: Union[numpy.ndarray, autoarray.structures.grids.two_d.grid_2d.Grid2D], indexes: numpy.ndarray)

Plot specific points of an input grid of (y,x) coordinates, which are specified according to the 1D or 2D indexes of the Grid2D.

This method allows us to color in points on grids that map between one another.

Parameters:
  • grid (Grid2D) – The grid of (y,x) coordinates that is plotted.
  • indexes – The 1D indexes of the grid that are colored in when plotted.