autogalaxy.plot.MatPlot2D#

class MatPlot2D[source]#

Bases: MatPlot2D

Visualizes data structures (e.g an Array2D, Grid2D, VectorField, etc.) using Matplotlib.

The Plotter is passed objects from the mat_wrap package which wrap matplotlib plot functions and customize the appearance of the plots of the data structure. If the values of these matplotlib wrapper objects are not manually specified, they assume the default values provided in the config.visualize.mat_* .ini config files.

The following data structures can be plotted using the following matplotlib functions:

  • Array2D:, using plt.imshow.

  • Grid2D: using plt.scatter.

  • Line: using plt.plot, plt.semilogy, plt.loglog or plt.scatter.

  • VectorField: using plt.quiver.

  • RectangularMapper: using plt.imshow.

  • MapperVoronoiNoInterp: using plt.fill.

Parameters:
  • units (Optional[Units]) – The units of the figure used to plot the data structure which sets the y and x ticks and labels.

  • figure (Optional[Figure]) – Opens the matplotlib figure before plotting via plt.figure and closes it once plotting is complete via plt.close.

  • axis (Optional[Axis]) – Sets the extent of the figure axis via plt.axis and allows for a manual axis range.

  • cmap (Optional[Cmap]) – Customizes the colormap of the plot and its normalization via matplotlib colors objects such as colors.Normalize and colors.LogNorm.

  • colorbar (Optional[Colorbar]) – Plots the colorbar of the plot via plt.colorbar and customizes its tick labels and values using method like cb.set_yticklabels.

  • colorbar_tickparams (Optional[ColorbarTickParams]) – Customizes the yticks of the colorbar plotted via plt.colorbar.

  • tickparams (Optional[TickParams]) – Customizes the appearances of the y and x ticks on the plot, (e.g. the fontsize), using plt.tick_params.

  • yticks (Optional[YTicks]) – Sets the yticks of the plot, including scaling them to new units depending on the Units object, via plt.yticks.

  • xticks (Optional[XTicks]) – Sets the xticks of the plot, including scaling them to new units depending on the Units object, via plt.xticks.

  • title (Optional[Title]) – Sets the figure title and customizes its appearance using plt.title.

  • ylabel (Optional[YLabel]) – Sets the figure ylabel and customizes its appearance using plt.ylabel.

  • xlabel (Optional[XLabel]) – Sets the figure xlabel and customizes its appearance using plt.xlabel.

  • text (Union[Text, List[Text], None]) – Sets any text on the figure and customizes its appearance using plt.text.

  • annotate (Union[Annotate, List[Annotate], None]) – Sets any annotations on the figure and customizes its appearance using plt.annotate.

  • legend (Optional[Legend]) – Sets whether the plot inclues a legend and customizes its appearance and labels using plt.legend.

  • output (Optional[Output]) – Sets if the figure is displayed on the user’s screen or output to .png using plt.show and plt.savefig

  • array_overlay (Optional[ArrayOverlay]) – Overlays an input Array2D over the figure using plt.imshow.

  • contour (Optional[Contour]) – Overlays contours of an input Array2D over the figure using plt.contour.

  • grid_scatter (Optional[GridScatter]) – Scatters a Grid2D of (y,x) coordinates over the figure using plt.scatter.

  • grid_plot (Optional[GridPlot]) – Plots lines of data (e.g. a y versus x plot via plt.plot, vertical lines via plt.avxline, etc.)

  • vector_yx_quiver (Optional[VectorYXQuiver]) – Plots a VectorField object using the matplotlib function plt.quiver.

  • patch_overlay (Optional[PatchOverlay]) – Overlays matplotlib patches.Patch objects over the figure, such as an Ellipse.

  • voronoi_drawer (Optional[VoronoiDrawer]) – Interpolations the reconstruction of a Mapper object from its irregular grid (e.g. Delaunay, Voronoi) to a uniform 2D array and plots it via plt.imshow().

  • voronoi_drawer – Draws a colored Voronoi mesh of pixels using plt.fill.

  • origin_scatter (Optional[OriginScatter]) – Scatters the (y,x) origin of the data structure on the figure.

  • mask_scatter (Optional[MaskScatter]) – Scatters an input Mask2d over the plotted data structure’s figure.

  • border_scatter (Optional[BorderScatter]) – Scatters the border of an input Mask2d over the plotted data structure’s figure.

  • positions_scatter (Optional[PositionsScatter]) – Scatters specific (y,x) coordinates input as a Grid2DIrregular object over the figure.

  • index_scatter (Optional[IndexScatter]) – Scatters specific coordinates of an input Grid2D based on input values of the Grid2D’s 1D or 2D indexes.

  • mesh_grid_scatter (Optional[MeshGridScatter]) – Scatters the PixelizationGrid of a Pixelization object.

  • light_profile_centres_scatter (Optional[LightProfileCentresScatter]) – Scatters the (y,x) centres of all LightProfile’s in the plotted object (e.g. a Tracer).

  • mass_profile_centres_scatter (Optional[MassProfileCentresScatter]) – Scatters the (y,x) centres of all MassProfile’s in the plotted object (e.g. a Tracer).

  • light_profile_centres_scatter – Scatters the (y,x) coordinates of the multiple image locations of the lens mass model.

  • tangential_critical_curves_plot (Optional[TangentialCriticalCurvesPlot]) – Plots the tangential critical curves of the lens mass model as colored lines.

  • radial_critical_curves_plot (Optional[RadialCriticalCurvesPlot]) – Plots the radial critical curves of the lens mass model as colored lines.

  • tangential_caustics_plot (Optional[TangentialCausticsPlot]) – Plots the tangential caustics of the lens mass model as colored lines.

  • radial_caustics_plot (Optional[RadialCausticsPlot]) – Plots the radial caustics of the lens mass model as colored lines.

Methods

get_subplot_shape

Get the size of a sub plotter in (total_y_pixels, total_x_pixels), based on the number of subplots that are going to be plotted.

plot_array

Plot an Array2D data structure as a figure using the matplotlib wrapper objects and tools.

plot_grid

Plot a grid of (y,x) Cartesian coordinates as a scatter plotter of points.

plot_mapper

set_for_subplot

Sets the is_for_subplot attribute for every MatWrap object in this MatPlot object by updating the is_for_subplot.

setup_subplot

Setup a new figure to be plotted on a subplot, which is used by a Plotter when plotting multiple images on a subplot.