Plot recipes

BranchingProcesses.branchingheatmap — Function
branchingheatmap(sol; time=nothing, func=nothing, ndim=nothing)

Plot a spatial heatmap of a function of the internal state of the particles alive at time in a BranchingProcessSolution, positioned at their spatial grid coordinates as assigned by tissue_growth!.

If the nodes of sol do not yet have spatial positions, tissue_growth! is run automatically using the spatial dimension configured in sol.prob.ndim. Pass ndim as a keyword argument to override or to use a solution created with ndim=0.

The heatmap is 1D (single-row heatmap), 2D (standard heatmap), or a 3D coloured scatter plot, depending on the spatial dimension.

Arguments

Keyword Arguments

  • time=nothing: Time at which to evaluate the heatmap. Defaults to the final time of the solution.
  • func=nothing: Function applied to each alive particle's interpolated state vector to produce the displayed scalar. Defaults to the first component for vector-valued states, or the value itself for scalar states.
  • ndim=nothing: Override the spatial dimension (1, 2, or 3). Defaults to sol.prob.ndim.

Examples

using BranchingProcesses, StochasticDiffEq, Plots
f(u, p, t) = 0.0
g(u, p, t) = 0.5
prob = SDEProblem(f, g, 1.0, (0.0, 3.0))
bp = ConstantRateBranchingProblem(prob, 1.0, 2; ndim=2)
sol = solve(bp, EM(); dt=0.01)
branchingheatmap(sol)                    # heatmap at final time
branchingheatmap(sol; time=1.5)          # heatmap at t=1.5
branchingheatmap(sol; func=u -> u[1]^2) # custom function

See also: tissue_growth!, animate_heatmaps

BranchingProcesses.branchingheatmap! — Function
branchingheatmap(sol; time=nothing, func=nothing, ndim=nothing)

Plot a spatial heatmap of a function of the internal state of the particles alive at time in a BranchingProcessSolution, positioned at their spatial grid coordinates as assigned by tissue_growth!.

If the nodes of sol do not yet have spatial positions, tissue_growth! is run automatically using the spatial dimension configured in sol.prob.ndim. Pass ndim as a keyword argument to override or to use a solution created with ndim=0.

The heatmap is 1D (single-row heatmap), 2D (standard heatmap), or a 3D coloured scatter plot, depending on the spatial dimension.

Arguments

Keyword Arguments

  • time=nothing: Time at which to evaluate the heatmap. Defaults to the final time of the solution.
  • func=nothing: Function applied to each alive particle's interpolated state vector to produce the displayed scalar. Defaults to the first component for vector-valued states, or the value itself for scalar states.
  • ndim=nothing: Override the spatial dimension (1, 2, or 3). Defaults to sol.prob.ndim.

Examples

using BranchingProcesses, StochasticDiffEq, Plots
f(u, p, t) = 0.0
g(u, p, t) = 0.5
prob = SDEProblem(f, g, 1.0, (0.0, 3.0))
bp = ConstantRateBranchingProblem(prob, 1.0, 2; ndim=2)
sol = solve(bp, EM(); dt=0.01)
branchingheatmap(sol)                    # heatmap at final time
branchingheatmap(sol; time=1.5)          # heatmap at t=1.5
branchingheatmap(sol; func=u -> u[1]^2) # custom function

See also: tissue_growth!, animate_heatmaps

branchingheatmap(sol; time=nothing, func=nothing, ndim=nothing)

Plot a spatial heatmap of a function of the internal state of the particles alive at time in a BranchingProcessSolution, positioned at their spatial grid coordinates as assigned by tissue_growth!.

If the nodes of sol do not yet have spatial positions, tissue_growth! is run automatically using the spatial dimension configured in sol.prob.ndim. Pass ndim as a keyword argument to override or to use a solution created with ndim=0.

The heatmap is 1D (single-row heatmap), 2D (standard heatmap), or a 3D coloured scatter plot, depending on the spatial dimension.

Arguments

Keyword Arguments

  • time=nothing: Time at which to evaluate the heatmap. Defaults to the final time of the solution.
  • func=nothing: Function applied to each alive particle's interpolated state vector to produce the displayed scalar. Defaults to the first component for vector-valued states, or the value itself for scalar states.
  • ndim=nothing: Override the spatial dimension (1, 2, or 3). Defaults to sol.prob.ndim.

Examples

using BranchingProcesses, StochasticDiffEq, Plots
f(u, p, t) = 0.0
g(u, p, t) = 0.5
prob = SDEProblem(f, g, 1.0, (0.0, 3.0))
bp = ConstantRateBranchingProblem(prob, 1.0, 2; ndim=2)
sol = solve(bp, EM(); dt=0.01)
branchingheatmap(sol)                    # heatmap at final time
branchingheatmap(sol; time=1.5)          # heatmap at t=1.5
branchingheatmap(sol; func=u -> u[1]^2) # custom function

See also: tissue_growth!, animate_heatmaps

BranchingProcesses.animate_heatmaps — Function
animate_heatmaps(sol::BranchingProcessSolution; nframes=50, func=nothing, ndim=nothing, kwargs...)

Create a Plots.Animation by producing heatmaps at nframes regularly spaced time points over the full time span of sol.

Note

This function requires Plots.jl to be loaded (using Plots). It is implemented as a package extension and is not available when only BranchingProcesses is loaded alone.

Arguments

Keyword Arguments

  • nframes=50: Number of animation frames.
  • func=nothing: Function applied to each particle's state; defaults to the first component for vector-valued states, or the value itself for scalar states.
  • ndim=nothing: Override the spatial dimension. Defaults to sol.prob.ndim.
  • kwargs...: Additional keyword arguments forwarded to branchingheatmap.

Returns

A Plots.Animation object. Use gif(anim, "output.gif"; fps=10) to save.

Examples

using BranchingProcesses, StochasticDiffEq, Plots
f(u, p, t) = 0.0
g(u, p, t) = 0.5
prob = SDEProblem(f, g, 1.0, (0.0, 3.0))
bp = ConstantRateBranchingProblem(prob, 1.0, 2; ndim=2)
sol = solve(bp, EM(); dt=0.01)
anim = animate_heatmaps(sol; nframes=30)
gif(anim, "growth.gif"; fps=10)

See also: branchingheatmap, tissue_growth!