Skip to content

Commit

Permalink
Merge pull request #2764 from JuliaReach/schillic/2763
Browse files Browse the repository at this point in the history
#2763 - Fix plotting of flat 1D sets
  • Loading branch information
schillic authored Jul 5, 2021
2 parents 23aa27c + 1309b8b commit fa88272
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
6 changes: 5 additions & 1 deletion src/Interfaces/AbstractPolyhedron_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,11 @@ function plot_recipe(P::AbstractPolyhedron{N}, ε=zero(N)) where {N}
@assert isbounded(P) "cannot plot an unbounded $(typeof(P))"

if dim(P) == 1
return plot_recipe(convert(Interval, P), ε)
Q = convert(Interval, P)
if diameter(Q) < _ztol(N) # flat interval
Q = Singleton(center(Q))
end
return plot_recipe(Q, ε)
else
vlist = convex_hull(vertices_list(P))
m = length(vlist)
Expand Down
22 changes: 13 additions & 9 deletions src/Plotting/plot_recipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -312,17 +312,21 @@ julia> plot(B, 1e-2) # faster but less accurate than the previous call
```
"""
@recipe function plot_lazyset(X::LazySet{N}, ε::N=N(PLOT_PRECISION)) where {N}
label --> DEFAULT_LABEL
grid --> DEFAULT_GRID
if DEFAULT_ASPECT_RATIO != :none
aspect_ratio --> DEFAULT_ASPECT_RATIO
end
seriesalpha --> DEFAULT_ALPHA
seriescolor --> DEFAULT_COLOR

if dim(X) == 1
plot_recipe(X, ε)
else
label --> DEFAULT_LABEL
grid --> DEFAULT_GRID
if DEFAULT_ASPECT_RATIO != :none
aspect_ratio --> DEFAULT_ASPECT_RATIO
x, y = plot_recipe(X, ε)
if length(x) == 1
seriestype := :scatter
end
seriesalpha --> DEFAULT_ALPHA
seriescolor --> DEFAULT_COLOR

x, y
else
# extract limits and extrema of already plotted sets
p = plotattributes[:plot_object]
lims = _extract_limits(p, plotattributes)
Expand Down

0 comments on commit fa88272

Please sign in to comment.