Visualization utilities
In this page we document several plotting utility functions that have been created to make the visualization of the output of Attractors.jl seamless. See the examples page for usage of all these plotting functions.
Note that most functions have an out-of-place and an in-place form, the in-place form always taking as a first input a pre-initialized Axis
to plot in while the out-of-place creates and returns a new figure object.
E.g.,
heatmap_basins_attractors(grid, basins, attractors; kwargs...)
heatmap_basins_attractors!(ax, grid, basins, attractors; kwargs...)
Common plotting keywords
Common keywords for plotting functions in Attractors.jl are:
ukeys
: the basin ids (unique keys, vector of integers) to use. By default all existing keys are used.access = [1, 2]
: indices of which dimensions of an attractor to select and visualize in a two-dimensional plot. Only these ids will be visualized. By default all are used.colors
: a dictionary mapping basin ids (i.e., including the-1
key) to a color. By default the JuliaDynamics colorscheme is used if less than 7 ids are present, otherwise random colors from the:darktest
colormap.markers
: dictionary mapping attractor ids to markers they should be plotted aslabels = Dict(ukeys .=> ukeys)
: how to label each attractor.add_legend = length(ukeys) < 7
: whether to add a legend mapping colors to labels.
Basins related
Attractors.heatmap_basins_attractors
— Functionheatmap_basins_attractors(grid, basins, attractors; kwargs...)
Plot a heatmap of found (2-dimensional) basins
of attraction and corresponding attractors
, i.e., the output of basins_of_attraction
.
Keyword arguments
- All the common plotting keywords.
Attractors.shaded_basins_heatmap
— Functionshaded_basins_heatmap(grid, basins, attractors, iterations; kwargs...)
Plot a heatmap of found (2-dimensional) basins
of attraction and corresponding attractors
. A matrix iterations
with the same size of basins
must be provided to shade the color according to the value of this matrix. A small value corresponds to a light color and a large value to a darker tone. This is useful to represent the number of iterations taken for each initial condition to converge. See also convergence_time
to store this iteration number.
Keyword arguments
show_attractors = true
: shows the attractor on plotmaxit = maximum(iterations)
: clip the values ofiterations
to
the value maxit
. Useful when there are some very long iterations and keep the range constrained to a given interval.
- All the common plotting keywords.
Continuation related
Attractors.plot_basins_curves
— Functionplot_basins_curves(fractions_curves, prange = 1:length(); kwargs...)
Plot the fractions of basins of attraction versus a parameter range, i.e., visualize the output of continuation
. See also plot_basins_attractors_curves
.
Keyword arguments
style = :band
: how to visualize the basin fractions. Choices are:band
for a band plot with cumulative sum = 1 or:lines
for a lines plot of each basin fractionseparatorwidth = 1, separatorcolor = "white"
: adds a line separating the fractions if the style is:band
axislegend_kwargs = (position = :lt,)
: propagated toaxislegend
if a legend is addedseries_kwargs = NamedTuple()
: propagated to the band or scatterline plot- Also all common plotting keywords.
Attractors.plot_attractors_curves
— Functionplot_attractors_curves(attractors_info, attractor_to_real, prange = 1:length(); kwargs...)
Same as in plot_basins_curves
but visualizes the attractor dependence on the parameter instead of their fraction. The function attractor_to_real
takes as input a StateSpaceSet
(attractor) and returns a real number so that it can be plotted versus the parameter axis. See also plot_basins_attractors_curves
.
Same keywords as plot_basins_curves
.
Attractors.plot_basins_attractors_curves
— Functionplot_basins_attractors_curves(
fractions_curves, attractors_info, a2rs [, prange]
kwargs...
)
Convenience combination of plot_basins_curves
and plot_attractors_curves
in a multi-panel plot that shares legend, colors, markers, etc. This function allows a2rs
to be a Vector
of functions, each mapping attractors into real numbers. Below the basins fractions plot, one additional panel is created for each entry in a2rs
. a2rs
can also be a single function, in which case only one panel is made.
Video output
Attractors.animate_attractors_continuation
— Functionanimate_attractors_continuation(
ds::DynamicalSystem, attractors_info, fractions_curves, prange, pidx;
kwargs...
)
Animate how the found system attractors and their corresponding basin fractions change as the system parameter is increased. This function combines the input and output of the continuation
function into a video output.
The input dynamical system ds
is used to evolve initial conditions sampled from the found attractors, so that the attractors are better visualized. attractors_info, fractions_curves
are the output of continuation
while ds, prange, pidx
are the input to continuation
.
Keyword arguments
savename = "attracont.mp4"
: name of video output file.framerate = 4
: framerate of video output.Δt, T
: propagated totrajectory
for evolving an initial condition sampled from an attractor.- Also all common plotting keywords.