# autolens.plot.VoronoiDrawer¶

class autolens.plot.VoronoiDrawer(**kwargs)

Draws Voronoi pixels from a MapperVoronoi object (see inversions.mapper). This includes both drawing each Voronoi cell and coloring it according to a color value.

The mapper contains the grid of (y,x) coordinate where the centre of each Voronoi cell is plotted.

This object wraps methods described in below:

https://matplotlib.org/3.3.2/api/_as_gen/matplotlib.pyplot.fill.html

__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. draw_voronoi_pixels(mapper, values, cmap, …) Draws the Voronoi pixels of the input mapper using its pixelization_grid which contains the (y,x) coordinate of the centre of every Voronoi cell. voronoi_polygons(voronoi[, radius]) Reconstruct infinite voronoi regions in a 2D diagram to finite regions.

Attributes

 config_dict config_folder
draw_voronoi_pixels(mapper: autoarray.inversion.mappers.voronoi.MapperVoronoi, values: numpy.ndarray, cmap: autoarray.plot.wrap.wrap_base.Cmap, colorbar: autoarray.plot.wrap.wrap_base.Colorbar, colorbar_tickparams: autoarray.plot.wrap.wrap_base.ColorbarTickParams = None)

Draws the Voronoi pixels of the input mapper using its pixelization_grid which contains the (y,x) coordinate of the centre of every Voronoi cell. This uses the method plt.fill.

Parameters: mapper (MapperVoronoi) – An object which contains the (y,x) grid of Voronoi cell centres. values – An array used to compute the color values that every Voronoi cell is plotted using. cmap (str) – The colormap used to plot each Voronoi cell. colorbar (Colorbar) – The Colorbar object in mat_base used to set the colorbar of the figure the Voronoi mesh is plotted on.
voronoi_polygons(voronoi, radius=None)

Reconstruct infinite voronoi regions in a 2D diagram to finite regions.

Parameters: voronoi (Voronoi) – The input Voronoi diagram that is being plotted. optional (radius,) – Distance to ‘points at infinity’. regions (list of tuples) – Indices of vertices in each revised Voronoi regions. vertices (list of tuples) – Grid2DIrregular for revised Voronoi vertices. Same as coordinates of input vertices, with ‘points at infinity’ appended to the end.