Skip to content

Plotting overview

FlexiChains contains a number of functions for visualising chains with Makie.jl and Plots.jl.

The Makie backend is more developed, and we recommend using that in the first instance.

FlexiChains can also be used with AlgebraOfGraphics.jl via the Tables.jl interface.

Available functions

Here is an overview of what is currently available:

Type of plotMakie.jlPlots.jl
Trace + mixed density (default)Makie.plotPlots.plot
Trace plotsFlexiChains.Makie.traceplotFlexiChains.Plots.traceplot
Density plotsMakie.densityPlots.density
HistogramsMakie.hist and Makie.stephistPlots.histogram
Mixed density plotsFlexiChains.Makie.mixeddensityFlexiChains.Plots.mixeddensity
Running mean plotsFlexiChains.Makie.meanplotFlexiChains.Plots.meanplot
Autocorrelation plotsFlexiChains.Makie.autocorplotFlexiChains.Plots.autocorplot
Rank plotsFlexiChains.Makie.rankplotFlexiChains.Plots.rankplot
Corner plotsPairPlots.pairplotStatsPlots.cornerplot
Violin plotsMakie.violinStatsPlots.violin
Energy plots🐌🐌
Forest plotsFlexiChains.Makie.forestplot🐌
Ridgeline plotsFlexiChains.Makie.ridgeline🐌
Pushforward plotsFlexiChains.Makie.pushforward_continuous, FlexiChains.Makie.pushforward_discrete, and FlexiChains.Makie.pushforward_hist🐌

All of the above functions have 'mutating' versions with a ! suffix.

Notice that FlexiChains provides separate functions for Plots.jl and Makie.jl backends, which are namespaced within the FlexiChains.Plots and FlexiChains.Makie modules, respectively. This is necessary for disambiguation, much like how Plots.plot() and Makie.plot() are different functions.

Compositionality

In general, the plotting interfaces in FlexiChains try to stay as close as possible to the way the original plotting libraries work. That means that you should be able to construct your own plots, insert a FlexiChains plot into a larger figure, and so on, using the interface provided by the original plotting library.

For example, with Makie you can do something like:

julia
# Set up a Makie figure
f = Makie.Figure()
# These functions provided / extended by FlexiChains
FlexiChains.Makie.traceplot!(f[1, 1], chn, param1)
Makie.density!(f[1, 2], chn, param2)
# This is some completely external Makie.jl plot
Makie.plot!(f[1, 3], randn(10, 10))
# Show the figure
f

And with Plots.jl you can do:

julia
# These functions provided / extended by FlexiChains
p1 = FlexiChains.Plots.traceplot(chn, param1)
p2 = Plots.density(chn, param2)
# This is some completely external Plots.jl plot
p3 = Plots.plot(randn(10, 10))
# Compose them with Plots.jl
plot([p1, p2, p3], layout=(3, 1))