API reference
This page documents the symbols defined by TDAplots.jl. using TDAplots also re-exports the full TDAmapper and MetricSpaces APIs; see those packages' documentation for their symbols.
| Purpose | Main entry points | Guide |
|---|---|---|
| Observations and Mapper | metricspace_plot, mapper_plot, node_colors | Mapper tutorial |
| Linked selection | mapper_explorer, MapperExplorer | Select a node |
| Graph/centroid embeddings | centroid, layout_generic, layout_* | Layouts |
| Homology intervals | persistence_plot, barcode_plot | Persistence |
| Density-mode clustering | tomato_graph_plot, tomato_persistence_plot | ToMATo views |
| Scaling utilities | rescale, colorscale | Practical guide |
TDAplots.MapperExplorerTDAplots._data_positionsTDAplots._diagram_limitsTDAplots._dim_strTDAplots._mode_stringTDAplots._node_geometryTDAplots.barcode_plotTDAplots.centroidTDAplots.colorscaleTDAplots.layout_diffmapTDAplots.layout_faTDAplots.layout_genericTDAplots.layout_hlleTDAplots.layout_icaTDAplots.layout_isomapTDAplots.layout_kpcaTDAplots.layout_landmarksTDAplots.layout_lemTDAplots.layout_lleTDAplots.layout_ltsaTDAplots.layout_mdsTDAplots.layout_pcaTDAplots.layout_ppcaTDAplots.layout_sfdpTDAplots.layout_shellTDAplots.layout_spectral_graphTDAplots.layout_springTDAplots.layout_stressTDAplots.layout_tsneTDAplots.layout_umapTDAplots.mapper_explorerTDAplots.mapper_plotTDAplots.metricspace_plotTDAplots.node_colorsTDAplots.node_colorsTDAplots.persistence_plotTDAplots.rescaleTDAplots.rescaleTDAplots.tomato_graph_plotTDAplots.tomato_persistence_plot
TDAplots.MapperExplorer — Type
MapperExplorerReturn value of mapper_explorer. Wraps the interactive Figure together with the selected_node observable.
Fields
figure::Figure: the two-panel figure (mapper graph + data scatter).selected_node::Observable{Union{Nothing,Int}}: the currently selected node id (nothingwhen no node is selected).
Displaying a MapperExplorer displays its figure, so you can return it from a REPL/notebook cell directly. You may also access result.figure explicitly.
TDAplots._data_positions — Method
_data_positions(M; data, dims)Compute the right-panel data positions. If data is given (a vector of points or tuples with 2 or 3 coordinates) it is used directly; otherwise the first 2–3 coordinates of M.X are taken, honoring dims like metricspace_plot.
Returns (positions, ndims).
TDAplots._diagram_limits — Function
_diagram_limits(diags, infinity=nothing)Compute axis limits and infinity value for a collection of persistence diagrams. Returns (t_lo, t_hi, infinity).
TDAplots._dim_str — Method
_dim_str(diag)Format the dimension of a PersistenceDiagram as a subscript string (e.g. H₀, H₁).
TDAplots._mode_string — Method
Find the most common string in a collection. In case of ties, join up to max_ties values with "/".
TDAplots._node_geometry — Method
_node_geometry(M; node_positions, node_size, node_values, layout_function)Compute the shared node geometry used by both mapper_plot and mapper_explorer: node positions (via layout_function unless given), node sizes (∝ cover-element size, rescaled, unless given) and node values (via node_colors unless given). Returns (node_positions, node_size, node_values, dim).
TDAplots.barcode_plot — Method
barcode_plot(diags; infinity=nothing)Plot a persistence barcode using Makie.
Accepts a single PersistenceDiagram or a Vector{PersistenceDiagram}. Bars are colored by homology dimension.
Keyword Arguments
infinity: value at which to clamp infinite intervals. Auto-detected ifnothing.
TDAplots.centroid — Method
centroid(M::AbstractMapper)Compute the centroid of each cover element, returning a dim × n_clusters matrix.
Each column is the mean of the points belonging to that cover element.
TDAplots.colorscale — Method
colorscale(v)Map a numeric vector v to a color vector using the :inferno color scheme.
Values are min-max normalized to [0, 1] before mapping.
TDAplots.layout_diffmap — Method
layout_diffmap(M::AbstractMapper; dim=2, kwargs...)Diffusion Maps layout of mapper nodes.
TDAplots.layout_fa — Method
layout_fa(M::AbstractMapper; dim=2, kwargs...)Factor Analysis layout of mapper nodes.
TDAplots.layout_generic — Method
layout_generic(M::AbstractMapper, f::Function)Apply a dimensionality reduction function f to the centroids of the mapper cover elements.
f should accept a dim × n matrix and return a outdim × n matrix. Returns a vector of Point{outdim} suitable for plotting.
TDAplots.layout_hlle — Method
layout_hlle(M::AbstractMapper; dim=2, kwargs...)Hessian Locally Linear Embedding layout of mapper nodes.
TDAplots.layout_ica — Method
layout_ica(M::AbstractMapper; dim=2, kwargs...)ICA (Independent Component Analysis) layout of mapper nodes.
Note: ICA uses a positional k argument rather than maxoutdim.
TDAplots.layout_isomap — Method
layout_isomap(M::AbstractMapper; dim=2, kwargs...)Isomap layout of mapper nodes.
TDAplots.layout_kpca — Method
layout_kpca(M::AbstractMapper; dim=2, kwargs...)Kernel PCA layout of mapper nodes.
TDAplots.layout_landmarks — Method
layout_landmarks(M::AbstractMapper; dim=2)Position each mapper node at the centroid of its cover element, projected to dim dimensions.
This uses the mean of each node's member points, including for Ball Mapper; the centroid need not coincide with the sampled landmark. No dimensionality reduction is fitted. For 2D/3D point clouds, set dim to match the ambient dimension; higher-dimensional inputs use the first dim coordinates.
TDAplots.layout_lem — Method
layout_lem(M::AbstractMapper; dim=2, kwargs...)Laplacian Eigenmaps layout of mapper nodes.
TDAplots.layout_lle — Method
layout_lle(M::AbstractMapper; dim=2, kwargs...)Locally Linear Embedding layout of mapper nodes.
TDAplots.layout_ltsa — Method
layout_ltsa(M::AbstractMapper; dim=2, kwargs...)Local Tangent Space Alignment layout of mapper nodes.
TDAplots.layout_mds — Method
layout_mds(M::AbstractMapper; dim=2, kwargs...)MDS (Multidimensional Scaling) layout of mapper nodes using cover element centroids.
TDAplots.layout_pca — Method
layout_pca(M::AbstractMapper; dim=2, kwargs...)PCA (Principal Component Analysis) layout of mapper nodes.
TDAplots.layout_ppca — Method
layout_ppca(M::AbstractMapper; dim=2, kwargs...)Probabilistic PCA layout of mapper nodes.
TDAplots.layout_sfdp — Method
layout_sfdp(M::AbstractMapper; dim=2, kwargs...)SFDP (Scalable Force-Directed Placement) layout using the mapper graph topology.
TDAplots.layout_shell — Method
layout_shell(M::AbstractMapper)Shell layout using the mapper graph topology. Always 2D.
TDAplots.layout_spectral_graph — Method
layout_spectral_graph(M::AbstractMapper; dim=2, kwargs...)Spectral graph layout using the mapper graph topology.
TDAplots.layout_spring — Method
layout_spring(M::AbstractMapper; dim=2, kwargs...)Spring (force-directed) layout using the mapper graph topology.
TDAplots.layout_stress — Method
layout_stress(M::AbstractMapper; dim=2, kwargs...)Stress majorization layout using the mapper graph topology.
TDAplots.layout_tsne — Method
layout_tsne(M::AbstractMapper; dim=2, kwargs...)t-SNE layout of mapper nodes.
TDAplots.layout_umap — Method
layout_umap(M::AbstractMapper; dim=2, kwargs...)UMAP layout of mapper nodes.
TDAplots.mapper_explorer — Method
mapper_explorer(M::AbstractMapper; data=nothing, node_values=nothing,
node_size=nothing, colormap=:viridis, edge_size=1,
layout_function=NetworkLayout.Spring(dim=2), markersize=6,
dims=nothing, inspector=false)Build an interactive two-panel exploration figure for a mapper result.
The left panel renders the mapper graph using the same rules as mapper_plot (nodes sized ∝ cover-element size, colored by node_values). The right panel scatters the original data points. Selecting a node — by clicking it, or by setting the returned observable — highlights that node's member points on the right (full opacity) while dimming the rest, and outlines the selected node on the left.
Return value
A MapperExplorer which behaves like the NamedTuple (figure, selected_node):
result.figure::Figure— the figure (also displayed automatically if you returnresultfrom a REPL/notebook cell).result.selected_node::Observable{Union{Nothing,Int}}— the selected node id, ornothing. Set it (result.selected_node[] = i) to drive the highlight programmatically; this is what tests exercise.
Keyword Arguments
data: a vector of points/tuples with 2 or 3 coordinates for the right panel. Defaults to the first 2–3 coordinates ofM.X(honoringdims).node_values: numeric values for coloring nodes (default:node_colors). Only numericnode_valuesare supported here (categorical coloring is not — usemapper_plotfor that).node_size: sizes for each node (default: ∝ cover-element size, rescaled).colormap: Makie colormap fornode_values(default::viridis).edge_size: line width for graph edges (default: 1).layout_function: a NetworkLayout algorithm for node positions (default:NetworkLayout.Spring(dim=2)).markersize: marker size for the right-panel data points (default: 6).dims: which dimensions ofM.Xto plot whendatais not given (e.g.[1, 3]). Defaults to the first 2 or 3 dimensions.inspector: iftrue, instantiate aDataInspectorso hovering a node shows a tooltip (default:false). Hover tooltips require an interactive backend (e.g. GLMakie/WGLMakie); on non-interactive backends this is a no-op. The node scatter always carries aninspector_label, so enabling aDataInspectoryourself works too.
Example
using GLMakie, TDAplots
using MetricSpaces.Datasets: sphere
X = sphere(200, dim=2)
fv = first.(X)
ic = TDAmapper.ImageCovers.R1Cover(fv, TDAmapper.IntervalCovers.Uniform(length=5, expansion=0.3))
M = classical_mapper(X, ic, TDAmapper.Refiners.DBscan(radius=0.2))
res = mapper_explorer(M; inspector=true)
res.figure # the figure (hover a node, or click it)
res.selected_node[] = 3 # programmatically select node 3
res.selected_node[] = nothing # clear the selectionTDAplots.mapper_plot — Method
mapper_plot(M::AbstractMapper; kwargs...)Plot a mapper graph using Makie.
Keyword Arguments
node_positions: positions for each node (default: Spring layout)node_size: sizes for each node (default: proportional to cover element size)node_values: values for coloring nodes (default: mean of first coordinate per cover element). Can be aVector{<:Number}(colorscale) orVector{<:AbstractString}(categorical legend).colormap: Makie colormap for numericnode_values(default::viridis)edge_size: line width for edges (default: 1)show_node_ids: iftrue, overlay each node's integer index (default:false)layout_function: a NetworkLayout algorithm (default:NetworkLayout.Spring(dim=2))
TDAplots.metricspace_plot — Method
metricspace_plot(X::EuclideanSpace; dims=nothing, color=nothing, colormap=:viridis, markersize=10)Plot a EuclideanSpace as a scatter plot using Makie.
Keyword Arguments
dims: which dimensions to plot (e.g.,[1, 3, 5]). Defaults to the first 2 or 3 dimensions.color: aVector{<:Number}(mapped to a colorscale with colorbar) or aVector{<:AbstractString}(categorical, with legend). Ifnothing, uses a default color.colormap: Makie colormap used whencoloris numeric (default::viridis).markersize: marker size (default: 10).
TDAplots.node_colors — Function
node_colors(M::AbstractMapper, v::Vector{<:Number}; f::Function=mean)Compute a summary value for each node (cover element) in the mapper graph.
For each cover element, applies f to the subset of v indexed by that element. If v is not provided, defaults to the first coordinate of each point.
TDAplots.node_colors — Method
node_colors(M::AbstractMapper, v::Vector{<:AbstractString}; f::Function=_mode_string)Compute a categorical label for each node by finding the most common string in each cover element.
TDAplots.persistence_plot — Method
persistence_plot(diags; persistence=false, infinity=nothing, markersize=10)Plot a persistence diagram using Makie.
Accepts a single PersistenceDiagram or a Vector{PersistenceDiagram} (e.g. from TDARipserer). Points are colored by homology dimension.
Keyword Arguments
persistence: iftrue, plot (birth, persistence) instead of (birth, death). Default:false.infinity: value at which to clamp infinite intervals. Auto-detected ifnothing.markersize: marker size for scatter points. Default:10.
TDAplots.rescale — Method
rescale(x; min=0, max=1)Rescale a numeric vector x to lie within [min, max].
TDAplots.rescale — Method
rescale(; min=0, max=1)Return a curried version of rescale.
TDAplots.tomato_graph_plot — Method
tomato_graph_plot(X::EuclideanSpace, g, values)Given a nonempty Euclidean space X with at least 2 coordinates, a graph g whose vertices match point IDs, and a numeric vector values (one per point), plot graph edges and observations colored by values. Inputs with more than 3 coordinates use their first 3 coordinates without fitting an embedding.
The plot uses a continuous colorbar. For a categorical cluster legend, use metricspace_plot with color=string.(labels) instead. Returns a Makie Figure.
TDAplots.tomato_persistence_plot — Method
tomato_persistence_plot(births_and_deaths; max_value_multiplier=1.3)Plot the nonempty ToMATo dictionary peak_point_id => [birth_density, death_density] as (birth_density, birth_density - death_density). To inspect recorded finite mode prominences before selecting a threshold, use a ToMATo run with τ=Inf; that run allows merging without a finite prominence cutoff.
death_density=Inf denotes an unmerged mode. Its resulting -Inf ordinate is displayed at max_value_multiplier times the largest finite prominence, or times the largest birth if no finite prominences exist. This is a display surrogate, not a measured finite lifetime; the helper does not specially mark these points. Returns a Makie FigureAxisPlot, whose .axis can be labelled.