visualise#

visualise(domain, color_by=('Collection',), objects_to_plot=None, marker_size=None, vmin=None, vmax=None, show_boundary=False, ax=None, figure_kwargs=None, add_cbar=True, shape_kwargs={}, scatter_kwargs={}, cbar_kwargs={}, show_temporary_shapes=False, add_scalebar=False, scalebar_kwargs={})#

Visualise a muspan domain with associated objects. Objects can be points or shapes, and can be coloured by various properties. The domain boundary can also be shown, and a scale bar can be added. Objects can be filtered by a query-like object. Appearence of points and shape objects can be customised using the scatter_kwargs and shape_kwargs dictionaries, respectively. The function returns a matplotlib figure and axis object for further manipulation or saving.

Parameters:
domainobject

The point cloud or domain to be visualized.

color_bystr, tuple, optional

Tuple of properties to color the points by, defaults to (‘Collection’,). If str, this is interpreted as (‘label’,string). See Notes for more details.

objects_to_plotquery-like, optional

List or query of object ids to plot, defaults to None.

cmapColormap, optional

Colormap to use, defaults to None.

marker_sizeint or float, optional

Size of the markers, defaults to None.

vminint or float, optional

Minimum value for the color scale, defaults to 0.

vmaxint or float, optional

Maximum value for the color scale, defaults to 1.

show_boundarybool, optional

Boolean to show the domain boundary, defaults to False.

axmatplotlib.axes.Axes, optional

Axis to plot the figure on, defaults to None.

figure_kwargsdict, optional

Dictionary of arguments to pass to the plt.figure function, defaults to None.

add_cbarbool, optional

Boolean to add a color bar to the plot, defaults to True.

shape_kwargsdict, optional

Dictionary of arguments which get passed to matplotlib.patches.PathPatch when drawing shapes

scatter_kwargsdict, optional

Dictionary of arguments which get passed to matplotlib.pyplot.scatter when plotting points

cbar_kwargsdict, optional

Dictionary of arguments to pass to matplotlib.pyplot.colorbar for plotting the colorbar

show_temporary_shapesbool, optional

If True, allow shapes in ‘__temp…’ collections to be visualised. If False, temporary objects made by MuSpAn included in ‘__temporary…’ collections will be invisible. Defaults to False.

add_scalebarbool, optional

Boolean to add a scale bar to the plot, defaults to False.

scalebar_kwargsdict, optional

Dictionary of arguments to pass to the AnchoredSizeBar function for plotting the scale bar, defaults to {}.

Returns:
figmatplotlib.figure.Figure

The figure object.

axmatplotlib.axes.Axes

The axis object.

Notes

The color_by argument can be a tuple of properties or a single string to color the objects by and there are a few options for this:

  • color_by=(‘Collection’,) will color the objects by their collection.

  • color_by=(‘label’,’my_label’) will color the objects by the label ‘my_label’.

  • color_by=’my_label’ will color the objects by the label ‘my_label’, interpreted as color_by=(‘label’,’my_label’).

  • color_by=(‘Random’,) will color the objects by a random color.

  • color_by=(‘constant’, a_color) will color the objects by a constant color, where a_color is a valid matplotlib color (e.g. ‘red’, ‘#FF0000’, [1,0,0,1] etc.).

For scalebar kwargs options, see matplotlib AnchoredSizeBar documentation.