Spline plot

Spline plot is a plot type for visualisation of terms in an UnfoldModel. Two subplots are generated for each spline term: 1) the basis function of the spline; 2) the density of the underlying covariate.

Multiple spline terms are arranged across columns. Dashed lines indicate spline knots.

Setup

Package and data loading

using Unfold, UnfoldMakie
import BSplineKit, DataFrames

df, pos = UnfoldMakie.example_data("TopoPlots.jl")
m1 = UnfoldMakie.example_data("UnfoldLinearModelwith1Spline");
m2 = UnfoldMakie.example_data("UnfoldLinearModelwith2Splines");

Spline plot with one spline term:

plot_splines(m1)
Example block output

Spline plot with two spline terms:

plot_splines(m2)
Example block output

Configurations of Spline plot

UnfoldMakie.plot_splinesFunction
plot_splines(m::UnfoldModel; kwargs...)
plot_splines!(f::Union{GridPosition, GridLayout, Figure}, m::UnfoldModel; kwargs...)

Visualization of spline terms in an UnfoldModel. Two subplots are generated for each spline term:
1) the basis function of the spline; 2) the density of the underlying covariate.
Multiple spline terms are arranged across columns.
Dashed lines indicate spline knots.

Arguments:

  • f::Union{GridPosition, GridLayout, Figure} Figure, GridLayout, or GridPosition to draw the plot.
  • m::UnfoldModel
    UnfoldModel with splines.
  • spline_axis::NamedTuple = (;)
    Here you can flexibly change configurations of spline subplots.
    To see all options just type ?Axis in REPL.
    Defaults: (ylabel = "Spline value", xlabelvisible = false, xticklabelsvisible = false, ylabelvisible = true)
  • density_axis::NamedTuple = (;)
    Here you can flexibly change configurations of density subplots.
    To see all options just type ?Axis in REPL.
    Defaults: (xautolimitmargin = (0, 0), ylabel = "Density value")
  • superlabel_config::NamedTuple = (;)
    Here you can flexibly change configurations of the Label on the top of the plot.
    To see all options just type ?Label in REPL.
    Defaults: (fontsize = 20, padding = (0, 0, 40, 0))

Shared plot configuration options

The shared plot options can be used as follows: type = (; key = value, ...)).
For example, plot_x(...; colorbar = (; vertical = true, label = "Test")).
Multiple defaults will be cycled until match.

Placing ; is important!

figure = NamedTuple() - use kwargs... of Makie.Figure

axis = NamedTuple() - use kwargs... of Makie.Axis

layout = (show_legend = true, use_colorbar = true) - check this page

mapping = (x = (:time,), y = (:estimate, :yhat, :y)) - use any mapping from AlgebraOfGraphics

visual = (colormap = :viridis,) - use kwargs... of Makie.series

legend = (orientation = :vertical, tellwidth = true, tellheight = false, halign = :right, valign = :center, title = "Splines", framevisible = false) - use kwargs... of Makie.Legend

colorbar = (vertical = true, tellwidth = true, tellheight = false, labelrotation = -1.5707963267948966) - use kwargs... of Makie.Colorbar

Return Value: Figure with splines and their density for basis functions.

source

This page was generated using Literate.jl.