Plotting (.pl)#

class spatialdata_plot.pl.basic.PlotAccessor(sdata)#

A class to provide plotting functions for SpatialData objects.

Parameters:

sdata (SpatialData) – The SpatialData object to provide plotting functions for.

Notes

This class provides a number of methods that can be used to generate plots of the data stored in a SpatialData object. These methods are accessed via the SpatialData.pl accessor.

render_images(element=None, *, channel=None, cmap=None, norm=None, palette=None, alpha=1.0, scale=None, grayscale=False, transfunc=None, colorbar='auto', colorbar_params=None, channels_as_legend=False)#

Render image elements in SpatialData.

In case of no elements specified, “broadcasting” of parameters is applied. This means that for any particular SpatialElement, we validate whether a given parameter is valid. If not valid for a particular SpatialElement the specific parameter for that particular SpatialElement will be ignored. If you want to set specific parameters for specific elements please chain the render functions: pl.render_images(...).pl.render_images(...).pl.show() .

Parameters:
  • element (str | None (default: None)) – The name of the image element to render. If None, all image elements in the SpatialData object will be used and all parameters will be broadcasted if possible.

  • channel (list[str] | list[int] | str | int | None (default: None)) – To select specific channels to plot. Can be a single channel name/int or a list of channel names/ints. If None, all channels will be used.

  • cmap (list[Colormap | str] | Colormap | str | None (default: None)) – Colormap or list of colormaps for continuous annotations, see matplotlib.colors.Colormap. Each colormap applies to a corresponding channel.

  • norm (list[Normalize] | Normalize | None (default: None)) – Colormap normalization for continuous annotations, see matplotlib.colors.Normalize. A single Normalize applies to all channels. A list of Normalize objects applies per-channel (length must match the number of channels).

  • palette (list[str] | str | None (default: None)) – Palette to color images. Can be a single palette name (broadcast to all channels) or a list matching the number of channels.

  • alpha (float | int (default: 1.0)) – Alpha value for the images. Must be a numeric between 0 and 1.

  • scale (str | None (default: None)) –

    Influences the resolution of the rendering. Possibilities include:

    1) None (default): The image is rasterized to fit the canvas size. For multiscale images, the best scale is selected before rasterization. 2) A scale name: Renders the specified scale ( of a multiscale image) as-is (with adjustments for dpi in show()). 3) “full”: Renders the full image without rasterization. In the case of multiscale images, the highest resolution scale is selected. Note that this may result in long computing times for large images.

  • grayscale (bool (default: False)) – Convert the image to grayscale before rendering using luminance weights (Rec. 601: 0.2989 R + 0.5870 G + 0.1140 B). Requires exactly 3 channels at the point of conversion — if transfunc is also provided, it runs first, and the result must have 3 channels. The grayscale image is rendered as a single-channel image with cmap="gray" unless an explicit cmap is given. Useful for de-emphasising H&E tissue when overlaying colored annotations. Cannot be combined with palette.

  • transfunc (Callable[[ndarray], ndarray] | list[Callable[[ndarray], ndarray]] | None (default: None)) –

    Transform(s) applied to the raw image array before normalization and rendering.

    Single callable: receives a numpy array of shape (c, y, x) (channels first) and must return an array of the same layout. The number of channels may change (e.g., stain deconvolution). Elementwise functions like np.log1p broadcast naturally. Note that reductions like np.percentile will compute a single value across all channels.

    List of callables: one per channel (length must match the number of selected channels). Each receives a (y, x) array for its channel and must return a (y, x) array. Use this when each channel needs independent treatment (e.g., different gamma corrections for different fluorescence markers).

    When combined with grayscale=True, transfunc runs first and grayscale is applied to the result.

  • colorbar (bool | str | None (default: 'auto')) – Whether to request a colorbar for continuous colors. Use "auto" (default) for automatic selection.

  • colorbar_params (dict[str, object] | None (default: None)) – Parameters forwarded to Matplotlib’s colorbar alongside layout hints such as loc, width, pad, and label.

  • channels_as_legend (bool (default: False)) – When True and rendering multiple channels, show a categorical legend mapping each channel name to its compositing color. The legend uses the legend_* parameters from show(). Ignored for single-channel and RGB(A) images. When multiple render_images calls use this flag on the same axes, all channel entries are combined into a single legend.

Notes

  • RGB(A) auto-detection: when the channel names are exactly {r, g, b} or {r, g, b, a} (case-insensitive) and no explicit cmap or palette is given, the image is rendered as true-color RGB(A) without colormaps.

  • Multi-channel compositing: when multiple channels are rendered with per-channel colormaps, they are additively blended. Colormaps that go from a color to white (rather than to transparent) will cause upper layers to occlude lower ones.

  • A single cmap is automatically broadcast to all selected channels.

Return type:

SpatialData

Returns:

sd.SpatialData A copy of the SpatialData object with the rendering parameters stored in its plotting tree.

render_labels(element=None, color=None, *, groups=None, contour_px=3, palette=None, cmap=None, norm=None, na_color='default', outline_alpha=0.0, fill_alpha=None, outline_color=None, scale=None, colorbar='auto', colorbar_params=None, table_name=None, table_layer=None, gene_symbols=None, transfunc=None)#

Render labels elements in SpatialData.

In case of no elements specified, “broadcasting” of parameters is applied. This means that for any particular SpatialElement, we validate whether a given parameter is valid. If not valid for a particular SpatialElement the specific parameter for that particular SpatialElement will be ignored. If you want to set specific parameters for specific elements please chain the render functions: pl.render_labels(...).pl.render_labels(...).pl.show() .

Parameters:
  • element (str | None (default: None)) – The name of the labels element to render. If None, all label elements in the SpatialData object will be used and all parameters will be broadcasted if possible.

  • color (tuple[float, ...] | list[float] | str | None (default: None)) – Can either be color-like (name of a color as string, e.g. “red”, hex representation, e.g. “#000000” or “#000000ff”, or an RGB(A) array as a tuple or list containing 3-4 floats within [0, 1]. If an alpha value is indicated, the value of fill_alpha takes precedence if given) or a string representing a key in sdata.table.obs or in the index of sdata.table.var. The latter can be used to color by categorical or continuous variables. If the color column is found in multiple locations, please provide the table_name to be used for the element if you would like a specific table to be used.

  • groups (list[str] | str | None (default: None)) – When using color and the key represents discrete labels, groups can be used to show only a subset of them. By default, non-matching labels are hidden. To show non-matching labels, set na_color explicitly.

  • palette (dict[str, str] | list[str] | str | None (default: None)) – Palette for discrete annotations. Can be a dictionary mapping category names to colors, a list of valid color names (must match the number of groups), a single named palette or matplotlib colormap name, or None.

  • contour_px (int | None (default: 3)) – Draw contour of specified width for each segment. Must be >= 2; contour_px=1 is rejected because a 1x1 erosion is the identity transformation and produces no visible outline. If None, fills entire segment, see skimage.morphology.erosion().

  • cmap (Colormap | str | None (default: None)) – Colormap for continuous annotations using ‘color’, see matplotlib.colors.Colormap. For categorical data, use palette instead.

  • norm (Normalize | None (default: None)) – Colormap normalization for continuous annotations, see matplotlib.colors.Normalize.

  • na_color (tuple[float, ...] | list[float] | str | None (default: 'default')) – Color for NA values and, when groups is set, for non-matching labels. When omitted, non-matching labels are hidden. Pass any explicit color (e.g. "lightgray") to show them in that color instead. Accepts a named color ("red"), a hex string ("#000000ff"), or an RGB/RGBA list ([1.0, 0.0, 0.0, 1.0]). Pass None to make NA values fully transparent.

  • outline_alpha (float | int (default: 0.0)) – Alpha value for the outline of the labels. Invisible by default.

  • fill_alpha (float | int | None (default: None)) – Alpha value for the fill of the labels. By default, it is set to 0.4 or, if a color is given that implies an alpha, that value is used for fill_alpha.

  • outline_color (tuple[float, ...] | list[float] | str | None (default: None)) – Color of the outline of the labels. Can either be a named color (“red”), a hex representation (“#000000”) or a list of floats that represent RGB/RGBA values (1.0, 0.0, 0.0, 1.0). If None, the outline inherits from the color parameter when it is a literal color, or uses data-driven per-label colors when color refers to a column.

  • scale (str | None (default: None)) –

    Influences the resolution of the rendering. Possibilities for setting this parameter:

    1) None (default). The image is rasterized to fit the canvas size. For multiscale images, the best scale is selected before the rasterization step. 2) Name of one of the scales in the multiscale image to be rendered. This scale is rendered as it is (exception: a dpi is specified in show(). Then the image is rasterized to fit the canvas and dpi). 3) “full”: render the full image without rasterization. In the case of a multiscale image, the scale with the highest resolution is selected. This can lead to long computing times for large images!

  • colorbar (bool | str | None (default: 'auto')) – Whether to request a colorbar for continuous colors. Use "auto" (default) for automatic selection.

  • colorbar_params (dict[str, object] | None (default: None)) – Parameters forwarded to Matplotlib’s colorbar alongside layout hints such as loc, width, pad, and label.

  • table_name (str | None (default: None)) – Name of the table containing the color columns.

  • table_layer (str | None (default: None)) – Layer of the AnnData table to use for coloring if color is in sdata.table.var_names. If None, sdata.table.X of the default table is used for coloring.

  • gene_symbols (str | None (default: None)) – Column name in sdata.table.var to use for looking up color. Use this when var_names are e.g. ENSEMBL IDs but you want to refer to genes by their symbols stored in another column of var. Mimics scanpy’s gene_symbols parameter.

  • transfunc (Callable[[float], float] | None (default: None)) – Optional transformation applied to the continuous color vector before normalization and colormap mapping.

Return type:

SpatialData

Returns:

sd.SpatialData A copy of the SpatialData object with the rendering parameters stored in its plotting tree.

render_points(element=None, color=None, *, alpha=None, groups=None, palette=None, na_color='default', cmap=None, norm=None, size=1.0, method=None, table_name=None, table_layer=None, gene_symbols=None, colorbar='auto', colorbar_params=None, datashader_reduction=None, transfunc=None)#

Render points elements in SpatialData.

In case of no elements specified, “broadcasting” of parameters is applied. This means that for any particular SpatialElement, we validate whether a given parameter is valid. If not valid for a particular SpatialElement the specific parameter for that particular SpatialElement will be ignored. If you want to set specific parameters for specific elements please chain the render functions: pl.render_points(...).pl.render_points(...).pl.show() .

Parameters:
  • element (str | None (default: None)) – The name of the points element to render. If None, all points elements in the SpatialData object will be used.

  • color (tuple[float, ...] | list[float] | str | None (default: None)) – Can either be color-like (name of a color as string, e.g. “red”, hex representation, e.g. “#000000” or “#000000ff”, or an RGB(A) array as a tuple or list containing 3-4 floats within [0, 1]. If an alpha value is indicated, the value of alpha takes precedence if given) or a string representing a key in sdata.table.obs. The latter can be used to color by categorical or continuous variables. If element is None, if possible the color will be broadcasted to all elements. For this, the table in which the color key is found must annotate the respective element (region must be set to the specific element). If the color column is found in multiple locations, please provide the table_name to be used for the elements.

  • alpha (float | int | None (default: None)) – Alpha value for the points. By default, it is set to 1.0 or, if a color is given that implies an alpha, that value is used instead.

  • groups (list[str] | str | None (default: None)) – When using color and the key represents discrete labels, groups can be used to show only a subset of them. By default, non-matching points are filtered out entirely. To show non-matching points, set na_color explicitly. If element is None, broadcasting behaviour is attempted (use the same values for all elements).

  • palette (dict[str, str] | list[str] | str | None (default: None)) – Palette for discrete annotations. Can be a dictionary mapping category names to colors, a list of valid color names (must match the number of groups), a single named palette or matplotlib colormap name, or None. If element is None, broadcasting behaviour is attempted (use the same values for all elements).

  • na_color (tuple[float, ...] | list[float] | str | None (default: 'default')) – Color for NA values and, when groups is set, for non-matching points. When omitted, non-matching points are hidden. Pass any explicit color (e.g. "lightgray") to show them in that color instead. Accepts a named color ("red"), a hex string ("#000000ff"), or an RGB/RGBA list ([1.0, 0.0, 0.0, 1.0]). Pass None to make NA values fully transparent.

  • cmap (Colormap | str | None (default: None)) – Colormap for continuous annotations using ‘color’, see matplotlib.colors.Colormap. If no palette is given and color refers to a categorical, the colors are sampled from this colormap.

  • norm (Normalize | None (default: None)) – Colormap normalization for continuous annotations, see matplotlib.colors.Normalize.

  • size (float | int (default: 1.0)) – Size of the points.

  • method (str | None (default: None)) – Whether to use 'matplotlib' or 'datashader'. When None, the method is chosen automatically based on the size of the data (datashader for >10 000 elements).

  • colorbar (bool | str | None (default: 'auto')) – Whether to request a colorbar for continuous colors. Use "auto" (default) for automatic selection.

  • colorbar_params (dict[str, object] | None (default: None)) – Parameters forwarded to Matplotlib’s colorbar alongside layout hints such as loc, width, pad, and label.

  • table_name (str | None (default: None)) – Name of the table containing the color(s) columns. If one name is given than the table is used for each spatial element to be plotted if the table annotates it. If you want to use different tables for particular elements, as specified under element.

  • table_layer (str | None (default: None)) – Layer of the table to use for coloring if color is in sdata.table.var_names. If None, the data in sdata.table.X is used for coloring.

  • gene_symbols (str | None (default: None)) – Column name in sdata.table.var to use for looking up color. Use this when var_names are e.g. ENSEMBL IDs but you want to refer to genes by their symbols stored in another column of var. Mimics scanpy’s gene_symbols parameter.

  • datashader_reduction (Optional[Literal['sum', 'mean', 'any', 'count', 'std', 'var', 'max', 'min']] (default: None)) – Reduction method for datashader when coloring by continuous values. When None, defaults to "sum".

  • transfunc (Callable[[float], float] | None (default: None)) – Optional transformation applied to the continuous color vector before normalization and colormap mapping.

Return type:

SpatialData

Returns:

sd.SpatialData A copy of the SpatialData object with the rendering parameters stored in its plotting tree.

render_shapes(element=None, color=None, *, fill_alpha=None, groups=None, palette=None, na_color='default', outline_width=None, outline_color=None, outline_alpha=None, cmap=None, norm=None, scale=1.0, method=None, table_name=None, table_layer=None, gene_symbols=None, shape=None, colorbar='auto', colorbar_params=None, datashader_reduction=None, transfunc=None)#

Render shapes elements in SpatialData.

In case of no elements specified, “broadcasting” of parameters is applied. This means that for any particular SpatialElement, we validate whether a given parameter is valid. If not valid for a particular SpatialElement the specific parameter for that particular SpatialElement will be ignored. If you want to set specific parameters for specific elements please chain the render functions: pl.render_points(...).pl.render_points(...).pl.show() .

Parameters:
  • element (str | None (default: None)) – The name of the shapes element to render. If None, all shapes elements in the SpatialData object will be used.

  • color (tuple[float, ...] | list[float] | str | None (default: None)) – Can either be color-like (name of a color as string, e.g. “red”, hex representation, e.g. “#000000” or “#000000ff”, or an RGB(A) array as a tuple or list containing 3-4 floats within [0, 1]. If an alpha value is indicated, the value of fill_alpha takes precedence if given) or a string representing a key in sdata.table.obs. The latter can be used to color by categorical or continuous variables. If element is None, if possible the color will be broadcasted to all elements. For this, the table in which the color key is found must annotate the respective element (region must be set to the specific element). If the color column is found in multiple locations, please provide the table_name to be used for the elements.

  • fill_alpha (float | int | None (default: None)) – Alpha value for the fill of shapes. By default, it is set to 1.0 or, if a color is given that implies an alpha, that value is used for fill_alpha. If an alpha channel is present in a cmap passed by the user, fill_alpha will overwrite the value present in the cmap.

  • groups (list[str] | str | None (default: None)) – When using color and the key represents discrete labels, groups can be used to show only a subset of them. By default, non-matching elements are hidden. To show non-matching elements, set na_color explicitly. If element is None, broadcasting behaviour is attempted (use the same values for all elements).

  • palette (dict[str, str] | list[str] | str | None (default: None)) – Palette for discrete annotations. Can be a dictionary mapping category names to colors, a list of valid color names (must match the number of groups), a single named palette or matplotlib colormap name, or None. If element is None, broadcasting behaviour is attempted (use the same values for all elements).

  • na_color (tuple[float, ...] | list[float] | str | None (default: 'default')) – Color for NA values and, when groups is set, for non-matching elements. When omitted, non-matching elements are hidden. Pass any explicit color (e.g. "lightgray") to show them in that color instead. Accepts a named color ("red"), a hex string ("#000000ff"), or an RGB/RGBA list ([1.0, 0.0, 0.0, 1.0]). Pass None to make NA values fully transparent.

  • outline_width (float | int | tuple[float | int, float | int] | None (default: None)) – Width of the border. If 2 values are given (tuple), 2 borders are shown with these widths (outer & inner). If outline_color and/or outline_alpha are used to indicate that one/two outlines should be drawn, the default outline widths 1.5 and 0.5 are used for outer/only and inner outline respectively.

  • outline_color (tuple[float, ...] | list[float] | str | tuple[tuple[float, ...] | list[float] | str] | None (default: None)) – Color of the border. Can either be a named color (“red”), a hex representation (“#000000”) or a list of floats that represent RGB/RGBA values (1.0, 0.0, 0.0, 1.0). If the hex representation includes alpha, e.g. “#000000ff”, and outline_alpha is not given, this value controls the opacity of the outline. If 2 values are given (tuple), 2 borders are shown with these colors (outer & inner). If outline_width and/or outline_alpha are used to indicate that one/two outlines should be drawn, the default outline colors “#000000” and “#ffffff are used for outer/only and inner outline respectively.

  • outline_alpha (float | int | tuple[float | int, float | int] | None (default: None)) – Alpha value for the outline of shapes. Invisible by default, meaning outline_alpha=0.0 if both outline_color and outline_width are not specified. Else, outlines are rendered with the alpha implied by outline_color, or with outline_alpha=1.0 if outline_color does not imply an alpha. For two outlines, alpha values can be passed in a tuple of length 2.

  • cmap (Colormap | str | None (default: None)) – Colormap for continuous annotations using ‘color’, see matplotlib.colors.Colormap. For categorical data, use palette instead.

  • norm (Normalize | None (default: None)) – Colormap normalization for continuous annotations, see matplotlib.colors.Normalize.

  • scale (float | int (default: 1.0)) – Value to scale shapes (circles and polygons).

  • method (str | None (default: None)) – Whether to use 'matplotlib' or 'datashader'. When None, the method is chosen automatically based on the size of the data (datashader for >10 000 elements).

  • colorbar (bool | str | None (default: 'auto')) – Whether to request a colorbar for continuous colors. Use "auto" (default) for automatic selection.

  • colorbar_params (dict[str, object] | None (default: None)) – Parameters forwarded to Matplotlib’s colorbar alongside layout hints such as loc, width, pad, and label.

  • table_name (str | None (default: None)) – Name of the table containing the color(s) columns. If one name is given than the table is used for each spatial element to be plotted if the table annotates it. If you want to use different tables for particular elements, as specified under element.

  • table_layer (str | None (default: None)) – Layer of the table to use for coloring if color is in sdata.table.var_names. If None, the data in sdata.table.X is used for coloring.

  • gene_symbols (str | None (default: None)) – Column name in sdata.table.var to use for looking up color. Use this when var_names are e.g. ENSEMBL IDs but you want to refer to genes by their symbols stored in another column of var. Mimics scanpy’s gene_symbols parameter.

  • shape (Optional[Literal['circle', 'hex', 'visium_hex', 'square']] (default: None)) – If None (default), the shapes are rendered as they are. Else, if either of “circle”, “hex” or “square” is specified, the shapes are converted to a circle/hexagon/square before rendering. If “visium_hex” is specified, the shapes are assumed to be Visium spots and the size of the hexagons is adjusted to be adjacent to each other.

  • datashader_reduction (Optional[Literal['sum', 'mean', 'any', 'count', 'std', 'var', 'max', 'min']] (default: None)) – Reduction method for datashader when coloring by continuous values. When None, defaults to "max".

  • transfunc (Callable[[float], float] | None (default: None)) – Optional transformation applied to the continuous color vector before normalization and colormap mapping.

Notes

  • Empty geometries will be removed at the time of plotting.

  • An outline_width of 0.0 leads to no border being plotted.

  • When passing a color-like to ‘color’, this has precedence over the potential existence as a column name.

Return type:

SpatialData

Returns:

sd.SpatialData A copy of the SpatialData object with the rendering parameters stored in its plotting tree.

show(coordinate_systems=None, *, legend_fontsize=None, legend_fontweight='bold', legend_loc='right margin', legend_fontoutline=None, na_in_legend=True, colorbar=True, colorbar_params=None, wspace=None, hspace=0.25, ncols=4, frameon=None, figsize=None, dpi=None, fig=None, title=None, pad_extent=0, ax=None, return_ax=False, save=None, show=None, scalebar_dx=None, scalebar_units='um', scalebar_params=None, legend_params=None)#

Execute the plotting tree and display the final figure.

Parameters:
  • coordinate_systems (list[str] | str | None (default: None)) – Name(s) of the coordinate system(s) to be plotted. If None, all coordinate systems that contain relevant elements (as specified in the render_* calls) are plotted automatically.

  • legend_fontsize (Union[int, float, Literal['xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'], None] (default: None)) – Font size for the legend text. Accepts numeric values or matplotlib font size strings (e.g. "small", "large").

  • legend_fontweight (Union[int, Literal['light', 'normal', 'medium', 'semibold', 'bold', 'heavy', 'black']] (default: 'bold')) – Font weight for the legend text (e.g. "bold", "normal").

  • legend_loc (str | None (default: 'right margin')) – Location of the legend. Standard matplotlib legend locations (e.g. "upper left") or "right margin", "left margin", "top margin", "bottom margin" to place the legend outside the axes.

  • legend_fontoutline (int | None (default: None)) – Stroke width for a white outline around legend text, improving readability on busy plots.

  • na_in_legend (bool (default: True)) – Whether to include NA / unmapped categories in the legend.

  • colorbar (bool (default: True)) – Global switch to enable/disable all colorbars. Per-layer settings are ignored when this is False.

  • colorbar_params (dict[str, object] | None (default: None)) – Global overrides passed to colorbars for all axes. Accepts the same keys as per-layer colorbar_params (e.g., loc, width, pad, label).

  • wspace (float | None (default: None)) – Horizontal spacing between panels (passed to matplotlib.gridspec.GridSpec).

  • hspace (float (default: 0.25)) – Vertical spacing between panels (passed to matplotlib.gridspec.GridSpec).

  • ncols (int (default: 4)) – Number of columns in the multi-panel grid.

  • frameon (bool | None (default: None)) – Whether to draw the axes frame. If None, the frame is hidden automatically for multi-panel plots.

  • figsize (tuple[float, float] | None (default: None)) – Size of the figure (width, height) in inches. The actual canvas size in pixels is dpi * figsize. If None, the matplotlib default is used (6.4, 4.8).

  • dpi (int | None (default: None)) – Resolution of the plot in dots per inch. If None, the matplotlib default is used (100.0).

  • fig (Figure | None (default: None)) –

    Deprecated since version Pass: axes created from your figure via ax instead.

  • title (list[str] | str | None (default: None)) – Title(s) for the plot. A single string is applied to all panels; a list must match the number of coordinate systems. If None, each panel is titled with its coordinate system name.

  • pad_extent (int | float (default: 0)) – Padding added around the computed spatial extent on all sides.

  • ax (list[Axes] | Axes | None (default: None)) – Pre-existing matplotlib axes to plot on. Can be a single Axes or a list matching the number of coordinate systems. If None, a new figure and axes are created.

  • return_ax (bool (default: False)) – Whether to return the axes object(s) instead of None.

  • save (str | Path | None (default: None)) – Path to save the figure to. If None, the figure is not saved.

  • show (bool | None (default: None)) – Whether to call plt.show() at the end. If None (default), the plot is shown automatically when running in non-interactive mode (scripts) and suppressed in interactive sessions (e.g. Jupyter). When ax is provided by the user, defaults to False to allow further modifications.

  • scalebar_dx (float | None (default: None)) – Physical size of one axes-unit in scalebar_units. If None, no scalebar is drawn. SpatialData coordinate systems carry no unit metadata, so this value must be supplied explicitly (e.g. 1.0 when axes are already in micrometers; the microns-per-pixel value when axes are in image pixels).

  • scalebar_units (str (default: 'um')) – Unit string for the scalebar (passed to matplotlib_scalebar.scalebar.ScaleBar). Only takes effect when scalebar_dx is set.

  • scalebar_params (dict[str, Any] | None (default: None)) – Extra keyword arguments forwarded to matplotlib_scalebar.scalebar.ScaleBar, e.g. {"location": "lower right", "color": "white", "length_fraction": 0.25}. See the matplotlib-scalebar documentation for the full list of options.

  • legend_params (dict[str, Any] | None (default: None)) – Bundled legend options; overrides the matching legend_* flat kwargs. Accepted keys: location (or loc), fontsize, fontweight, fontoutline, na_in_legend. Unknown keys raise ValueError.

Return type:

Axes | list[Axes] | None

Returns:

Axes | list[Axes] | None The axes object(s) if return_ax=True, otherwise None.

property sdata: SpatialData#

The SpatialData object to provide plotting functions for.