Visualizations
Several plotting utility functions 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 all 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.,
fig = 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 (as inanimate_attractors_continuation).colors: a dictionary mapping basin ids (i.e., including the-1key) to a color. By default the JuliaDynamics colorscheme is used if less than 7 ids are present, otherwise random colors from the:darktestcolormap.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.axislegend_kwargs = (position = :lt,): propagated toaxislegendif a legend is added
Basins related
Attractors.plot_attractors — Function
plot_attractors(attractors::Dict{Int, StateSpaceSet}; kwargs...)Plot the attractors as a scatter plot.
Keyword arguments
- All the common plotting keywords. Particularly important is the
accesskeyword. sckwargs = (strokewidth = 0.5, strokecolor = :black,): additional keywords propagated to theMakie.scatterfunction that plots the attractors.
Attractors.heatmap_basins_attractors — Function
heatmap_basins_attractors(BoA::ArrayBasinsOfAttraction; kwargs...)
heatmap_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.
The second function signature exists for backwards compatibility
Keyword arguments
- All the common plotting keywords and
sckwargsas inplot_attractors.
Attractors.shaded_basins_heatmap — Function
shaded_basins_heatmap(BoA::ArrayBasinsOfAttraction, iterations; kwargs...)
shaded_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.
The second function signature exists for backwards compatibility
Keyword arguments
show_attractors = true: shows the attractor on plotmaxit = maximum(iterations): clip the values ofiterationsto
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 — Function
plot_basins_curves(fractions_cont [, prange]; kw...)Plot the fractions of basins of attraction versus a parameter range/curve, i.e., visualize the output of global_continuation. See also plot_basins_attractors_curves and plot_continuation_curves.
Keyword arguments
style = :band: how to visualize the basin fractions. Choices are:bandfor a band plot with cumulative sum = 1 or:linesfor a lines plot of each basin fractionseparatorwidth = 1, separatorcolor = "white": adds a line separating the fractions if the style is:bandfiller = NaN: filler value to use for basin fractions for attractor IDs that do not exist at a continuation step when the style is:lines(filler is always0for:bandstyle).series_kwargs = NamedTuple(): propagated to the band or scatterline plot- Also all common plotting keywords.
Attractors.plot_attractors_curves — Function
plot_attractors_curves(attractors_cont, attractor_to_real [, prange]; kw...)Same as in plot_basins_curves but visualize the attractor dependence on the parameter(s) instead of their basin 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_continuation_curves.
Attractors.plot_basins_attractors_curves — Function
plot_basins_attractors_curves(
fractions_cont, attractors_cont, 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.
Attractors.plot_continuation_curves — Function
plot_continuation_curves(continuation_info [, prange]; kwargs...)Same as in plot_basins_curves but visualize any arbitrary quantity characterizing the continuation. Hence, the continuation_info is of exactly the same format as fractions_cont: a vector of dictionaries, each dictionary mapping attractor IDs to real numbers. continuation_info is meant to accompany attractors_cont in plot_attractors_curves.
To produce continuation_info from attractors_cont you can do something like:
continuation_info = map(attractors_cont) do attractors
Dict(k => f(A) for (k, A) in attractors)
endwith f your function of interest that returns a real number.
Keyword arguments
series_kwargs: named tuple of arguments propagated toMakie.scatterlines!that plots the curves.- Also all common plotting keywords.
Video output
Attractors.animate_attractors_continuation — Function
animate_attractors_continuation(
ds::DynamicalSystem, gco::GlobalContinuationOutput; kw...
)Animate how the found system attractors and their corresponding basin fractions change along a global_continuation. This function combines the input and output of the global_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.
Keyword arguments
savename = "globalcont.mp4": name of video output file.framerate = 4: framerate of video output.Δt, T: propagated totrajectoryfor evolving an initial condition sampled from an attractor.- Also all common plotting keywords.
figure, axis, fracaxis, legend: named tuples propagated as keyword arguments to the creation of theFigure, theAxis, the "bar-like" axis containing the fractions, and theaxislegendthat adds the legend (ifadd_legend = true).add_legend = true: whether to display the axis legend.
Continuation plot animation
In addition to animating the attractors scatterplot, the plot of plot_attractors_curves can be added below the main attractor plot. It is animated by a dashed line that moves as the parameter is changed.
This is enabled by providing a non-nothing keyword for a2rs, and the behavior of plot is controlled by the following keywords:
a2rs: a vector of functions that map attractors to real numbers.prange = 1:length(attractors_cont): range of parameter values to plot on the x-axis of the additional plot(s). If given directly toanimate_attractors_continuationit is obtained from there.series_kwargs = NamedTuple(): named tuple of arguments propagated toMakie.scatterlines!that plots the curves.a2rs_ratio = 0.5: the height ratio of the additional plot(s) relative to the main attractor plot.a2rs_ylabels: vector of y-axis labels for the additional plot(s).parameter_name = "parameter". Name of the x-axis of the additional plot(s).vline_kwargs = (linestyle = :dash, linewidth = 3, color = "black"): named tuple of arguments propagated toMakie.vlines!that plots the vertical dashed line moving as the parameter is changed.