Tutorials

Tutorials#

Entry-point material for learning the API on synthetic data.

Getting started

The fluent .pl API, layering, and styling on the in-memory blobs dataset. Ideal first read.

Getting started with spatialdata-plot
Colour and palettes

How color= resolves, the v0.3.0 groups behaviour, and building perceptually well-spaced or colourblind-safe palettes with make_palette and make_palette_from_data.

Colour and palettes in spatialdata-plot
Multi-panel colouring

Render several colourings at once by passing a list to color=, scanpy-style, with per-panel legends/colourbars, shared palette/cmap, and ncols grid control.

Multi-panel colouring in spatialdata-plot
Speeding up rendering

Keep rendering fast on large data: automatic rasterization and scale selection for images, and the datashader backend for large collections of shapes and points.

Speeding up the rendering of large data
Rendering elements as points

Draw shapes and label masks as one dot per centroid with as_points=True — a fast overview that trades geometry for speed, including the matplotlib → datashader switch above ~50k elements.

Rendering elements as points with as_points
Scalebars

Add a physical scalebar with scalebar_dx, choose units, and style placement, colour, length and fonts through scalebar_params.

Scalebars in spatialdata-plot
Marker shapes

Draw circle elements as circles, hexagons, or squares with shape=, and render Visium spots as a hex grid with shape="visium_hex".

Marker shapes for circle elements in spatialdata-plot
Multichannel & fluorescence images

Render multiplexed and fluorescence images: select channels by name, composite them with per-channel palette LUTs, fix heavy-tailed contrast per channel, and label the composite with channels_as_legend.

Multichannel and fluorescence images in spatialdata-plot
Cropping a plot

Zoom into a bounding box with crop_coord — every layer windowed at draw time, images rasterized for the window only, and how it differs from bounding_box_query.

Cropping a plot with crop_coord