Skip to content

Commit

Permalink
Merge pull request #276 from JuliaReach/mforets/272
Browse files Browse the repository at this point in the history
Fix hyperrectangle plot
  • Loading branch information
Marcelo Forets authored Mar 3, 2018
2 parents b6a0495 + 2c123d2 commit 681574c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/plot_recipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ julia> B = BallInf(ones(2), 0.1)
julia> plot(2.0 * B)
```
### Algorithm
For any 2D lazy set we compute its box overapproximation, followed by the list of
vertices. A post-processing `convex_hull` is applied to the vertices list;
this ensures that the shaded area inside the convex hull of the vertices is covered
correctly.
### Notes
This recipe detects if the axis-aligned approximation is such that the first two
Expand All @@ -30,7 +37,7 @@ plotting singletons.
color="blue", label="", grid=true, alpha=0.5)

P = Approximations.overapproximate(S)
vlist = hcat(vertices_list(P)...).'
vlist = hcat(convex_hull(vertices_list(P))...).'
(x, y) = vlist[:, 1], vlist[:, 2]

seriestype := norm(vlist[1, :] - vlist[2, :]) 0 ? :scatter : :shape
Expand All @@ -56,6 +63,13 @@ julia> B1 = BallInf(zeros(2), 0.4)
julia> B2 = BallInf(ones(2), 0.4)
julia> plot([B1, B2])
```
### Algorithm
For each 2D lazy set in the array we compute its box overapproximation, followed
by the list of vertices. A post-processing `convex_hull` is applied to the vertices list;
this ensures that the shaded area inside the convex hull of the vertices is covered
correctly.
"""
@recipe function plot_lazyset(arr::Vector{<:LazySet};
seriescolor="blue", label="", grid=true,
Expand All @@ -65,7 +79,7 @@ julia> plot([B1, B2])

for S in arr
Pi = Approximations.overapproximate(S)
vlist = hcat(vertices_list(Pi)...).'
vlist = hcat(convex_hull(vertices_list(Pi))...).'
@series (x, y) = vlist[:, 1], vlist[:, 2]
end
end
Expand Down

0 comments on commit 681574c

Please sign in to comment.