gaioguys / GAIO.jl

A Julia package for set oriented computations.
MIT License
9 stars 4 forks source link

use MakieCore for plotting, move unnecessary dependencies to examples folder #62

Closed April-Hannah-Lena closed 1 year ago

April-Hannah-Lena commented 1 year ago

We can remove nearly one third of dependencies by separating the examples environment from the src environment. For testing the package examples you can call

julia> cd("path/to/GAIO.jl/examples")

pkg> activate .

pkg> dev ../

pkg> instantiate

This will activate the Project.toml file in examples and then add the local version of GAIO.jl so you can test code changes on all examples, without filling the source Project.toml with dependencies that GAIO.jl doesn't actually need.

We can further remove the largest dependencies (Makie, GMakie, WGLMakie) by using MakieCore's recipe system. This also makes the plotting much more powerful, since all kwargs for MeshScatter are automagicallly usable in plotting BoxSets / BoxFuns. It also automatically adds mutating versions of plot, which means you can use all the power of Makie with whatever backend you want. For example, the new invariant_measure_2d.jl below.

There is one technicality to consider, which is that Makie also exports Box, so using Makie and GAIO will cause an ambiguity. This is easily resolved though by simply calling using GLMakie: plot instead of just using GLMakie to only pull Makie's plot function into the namespace.

using WGLMakie: plot!, Figure, Axis3
using GAIO

# the Henon map
a, b = 1.4, 0.3
f((x,y)) = (1 - a*x^2 + y, b*x)

center, radius = (0, 0), (3, 3)
P = BoxPartition(Box(center, radius))
F = BoxMap(f, P)
A = relative_attractor(F, P[:], steps = 16)

T = TransferOperator(F, A)
λ, ev = eigs(T)

# Plot the map at a nice viewing angle
fig = Figure()
ax = Axis3(fig[1,1], azimuth = -3*pi/5)
plot!(ax, abs ∘ (x -> 0.1*x) ∘ ev[1])

fig

Henon