Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#921 - Close vertex list for plotting #937

Merged
merged 1 commit into from
Dec 10, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions src/plot_recipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ plotting singletons.
vlist = transpose(hcat(convex_hull(vertices_list(P))...))
(x, y) = vlist[:, 1], vlist[:, 2]

# add first vertex to "close" the polygon
push!(x, vlist[1, 1])
push!(y, vlist[1, 2])

seriestype := norm(vlist[1, :] - vlist[2, :]) ≈ 0 ? :scatter : :shape

x, y
Expand Down Expand Up @@ -92,7 +96,13 @@ correctly.
@assert dim(X) == 2 "cannot plot a $(dim(X))-dimensional set"
Pi = Approximations.overapproximate(X)
vlist = transpose(hcat(convex_hull(vertices_list(Pi))...))
@series (x, y) = vlist[:, 1], vlist[:, 2]
x, y = vlist[:, 1], vlist[:, 2]

# add first vertex to "close" the polygon
push!(x, vlist[1, 1])
push!(y, vlist[1, 2])

@series (x, y)
end
end

Expand Down Expand Up @@ -127,6 +137,10 @@ julia> plot(randn(2, 2) * B, 1e-3);
vlist = transpose(hcat(vertices_list(P)...))
(x, y) = vlist[:, 1], vlist[:, 2]

# add first vertex to "close" the polygon
push!(x, vlist[1, 1])
push!(y, vlist[1, 2])

x, y
end

Expand Down Expand Up @@ -163,7 +177,13 @@ julia> plot([B1, B2], 1e-4);
@assert dim(X) == 2 "cannot plot a $(dim(X))-dimensional set"
Pi = Approximations.overapproximate(X, ε)
vlist = transpose(hcat(vertices_list(Pi)...))
@series (x, y) = vlist[:, 1], vlist[:, 2]
x, y = vlist[:, 1], vlist[:, 2]

# add first vertex to "close" the polygon
push!(x, vlist[1, 1])
push!(y, vlist[1, 2])

@series (x, y)
end
end

Expand Down Expand Up @@ -214,7 +234,11 @@ julia> plot(P);
vlist = transpose(hcat(points...))
(x, y) = vlist[:, 1], vlist[:, 2]

x, y
# add first vertex to "close" the polygon
push!(x, vlist[1, 1])
push!(y, vlist[1, 2])

x, y
end

"""
Expand Down Expand Up @@ -269,7 +293,13 @@ It is assumed that the given vector of polytopes is two-dimensional.
@assert dim(Pi) == 2 "cannot plot a $(dim(Pi))-dimensional polytope"
points = convex_hull(vertices_list(Pi))
vlist = transpose(hcat(points...))
@series (x, y) = vlist[:, 1], vlist[:, 2]
x, y = vlist[:, 1], vlist[:, 2]

# add first vertex to "close" the polygon
push!(x, vlist[1, 1])
push!(y, vlist[1, 2])

@series (x, y)
end
end

Expand Down