Skip to content

Commit 68a811b

Browse files
authored
Merge pull request #365 from JuliaReach/schillic/doc_vectorfield
Document plotting of vector fields
2 parents 75fc906 + f04f35e commit 68a811b

4 files changed

Lines changed: 63 additions & 7 deletions

File tree

docs/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
33
DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244"
44
LazySets = "b4f0291d-fe17-52bc-9479-3d1a343d9043"
5+
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
56

67
[compat]
78
Documenter = "1"
89
DocumenterCitations = "1.3"
910
LazySets = "5 - 6"
11+
Plots = "1"

docs/make.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
ENV["GKSwstype"] = "100" # prevent plots from opening interactively
2+
13
using Documenter, MathematicalSystems, DocumenterCitations
2-
import LazySets
4+
import LazySets, Plots
35

46
DocMeta.setdocmeta!(MathematicalSystems, :DocTestSetup,
57
:(using MathematicalSystems); recursive=true)
@@ -14,10 +16,11 @@ makedocs(; sitename="MathematicalSystems.jl",
1416
pagesonly=true,
1517
plugins=[bib],
1618
pages=["Home" => "index.md",
17-
"Manual" => Any["Overview of System Types" => "man/systems.md"],
18-
"Library" => Any["Types" => "lib/types.md",
19-
"Methods" => "lib/methods.md",
20-
"Internals" => "lib/internals.md"],
19+
"Manual" => ["Overview of System Types" => "man/systems.md"
20+
"Vector Fields" => "man/vectorfield.md"],
21+
"Library" => ["Types" => "lib/types.md",
22+
"Methods" => "lib/methods.md",
23+
"Internals" => "lib/internals.md"],
2124
"Bibliography" => "bibliography.md",
2225
"About" => "about.md"])
2326

docs/src/man/vectorfield.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Vector Fields
2+
3+
Vector fields can be plotted via the (unexported)
4+
[`MathematicalSystems.VectorField`](@ref) type. First we give an example where
5+
the vector field is represented by a function that takes a two-dimensional state
6+
vector and returns the corresponding two-dimensional (derivative) vector:
7+
8+
```@example vector_fields
9+
using MathematicalSystems, Plots
10+
11+
f(x) = [2*x[2], -x[1]];
12+
13+
V = MathematicalSystems.VectorField(f);
14+
15+
plot(V)
16+
```
17+
18+
Alternatively, one can also pass a continuous system:
19+
20+
```@example vector_fields
21+
S = LinearContinuousSystem([0.0 2; -1 0])
22+
23+
V = MathematicalSystems.VectorField(S);
24+
25+
plot(V)
26+
```
27+
28+
The above example shows the default grid of 20×20 points for the range
29+
``[-3, 3] × [-3, 3]``. A custom grid can be passed via the `grid_points` keyword
30+
argument, which takes a pair `(x, y)` whose entries specify ranges for the x and
31+
y coordinates of the grid points. For instance:
32+
33+
```@example vector_fields
34+
xrange = range(-1, stop=3, length=5);
35+
36+
yrange = range(-5, stop=2, length=8);
37+
38+
plot(V; grid_points=(xrange, yrange))
39+
```
40+
41+
The implementation supports projective plotting of vector fields with more than
42+
two output dimensions. For that, one can use the `dims` keyword argument to pass
43+
a vector with the two dimensions to plot:
44+
45+
```@example vector_fields
46+
f(x) = [2*x[2], 42, -x[1]];
47+
48+
V = MathematicalSystems.VectorField(f);
49+
50+
plot(V; dims=[1, 3])
51+
```

src/vector_field.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@ end
126126
"""
127127
VectorField{T<:Function}
128128
129-
Type that computes the vector field of an `AbstractContinuousSystem`.
129+
Type that represents the vector field of an `AbstractContinuousSystem`.
130130
131131
### Fields
132132
133-
- `field` -- function for calculating the vector field
133+
- `field` -- function for evaluating the vector field at a given point
134134
"""
135135
struct VectorField{T<:Function}
136136
field::T

0 commit comments

Comments
 (0)